aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/open311.t
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2019-10-30 19:28:55 +0100
committerMarius Halden <marius.h@lden.org>2019-10-30 19:28:55 +0100
commit377bd96aab7cad3434185c30eb908c9da447fe40 (patch)
tree7ec5527e205d5b62caaa862a7de8cd25199c8bf0 /t/app/controller/open311.t
parent56f61b1441070aa0b9ddcfc74aca46c20313609f (diff)
parent92b253904062edd533e55c22824de6fd01e2f7c1 (diff)
Merge tag 'v2.6' into fiksgatami-dev
Diffstat (limited to 't/app/controller/open311.t')
-rw-r--r--t/app/controller/open311.t41
1 files changed, 40 insertions, 1 deletions
diff --git a/t/app/controller/open311.t b/t/app/controller/open311.t
index 9f4f594fe..79fe159a3 100644
--- a/t/app/controller/open311.t
+++ b/t/app/controller/open311.t
@@ -6,7 +6,7 @@ my $mech = FixMyStreet::TestMech->new;
$mech->get_ok('/open311.cgi/v2/requests.rss?jurisdiction_id=fiksgatami.no&status=open&agency_responsible=1854');
like $mech->uri, qr[/open311/v2/requests\.rss\?.{65}]; # Don't know order parameters will be in now
-$mech->create_problems_for_body(2, 2237, 'Around page');
+my ($problem1, $problem2) = $mech->create_problems_for_body(2, 2237, 'Around page');
$mech->get_ok('/open311/v2/requests.xml?jurisdiction_id=foo&status=open&agency_responsible=2237');
$mech->content_contains('<description>Around page Test 2 for 2237: Around page Test 2 for 2237 Detail</description>');
$mech->content_contains('<interface_used>Web interface</interface_used>');
@@ -18,4 +18,43 @@ my $problems = $json->{requests}[0]{request};
is @$problems, 2;
like $problems->[0]{description}, qr/Around page Test/;
+subtest "non_public reports aren't available" => sub {
+ $problem1->update({
+ non_public => 1,
+ detail => 'This report is now private',
+ });
+ $mech->get_ok('/open311/v2/requests.json?jurisdiction_id=foo');
+ $json = decode_json($mech->content);
+ $problems = $json->{requests}[0]{request};
+ is @$problems, 1;
+ like $problems->[0]{description}, qr/Around page Test/;
+ $mech->content_lacks('This report is now private');
+
+ my $problem_id = $problem1->id;
+ $mech->get_ok("/open311/v2/requests/$problem_id.json?jurisdiction_id=foo");
+ $json = decode_json($mech->content);
+ $problems = $json->{requests}[0]{request};
+ is @$problems, 0;
+};
+
+subtest "hidden reports aren't available" => sub {
+ $problem1->update({
+ non_public => 0,
+ detail => 'This report is now hidden',
+ state => "hidden",
+ });
+ $mech->get_ok('/open311/v2/requests.json?jurisdiction_id=foo');
+ $json = decode_json($mech->content);
+ $problems = $json->{requests}[0]{request};
+ is @$problems, 1;
+ like $problems->[0]{description}, qr/Around page Test/;
+ $mech->content_lacks('This report is now hidden');
+
+ my $problem_id = $problem1->id;
+ $mech->get_ok("/open311/v2/requests/$problem_id.json?jurisdiction_id=foo");
+ $json = decode_json($mech->content);
+ $problems = $json->{requests}[0]{request};
+ is @$problems, 0;
+};
+
done_testing();