aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/open311.t
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2019-04-12 17:32:06 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-04-23 17:34:00 +0100
commit022a7f3366b149a97124f5c8c57f6682b5fcc7f6 (patch)
treedae76e282c4c099cca9b99f52eeeb2a04a29c9eb /t/app/controller/open311.t
parent49e1578a3c2be13079e8a05ec18074b84401919e (diff)
[Open311] Ensures non_public/hidden reports aren’t visible at /open311
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();