aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-10-20 17:02:45 +0100
committerDave Arter <davea@mysociety.org>2016-10-31 13:18:42 +0000
commit15e9a1ab8c399b25bb212a3400c0361a41c9abc6 (patch)
tree549d6721f5b53767a6b60afcaeb312652b3fe312 /t
parent0a9c2ea426e8477ad302582e41756730965ea8c8 (diff)
Pre-filter map pages if user has categories assigned
This pre-filters the 'all reports' link in the main nav and the /around page reached via the front page postcode form
Diffstat (limited to 't')
-rw-r--r--t/app/controller/index.t17
1 files changed, 17 insertions, 0 deletions
diff --git a/t/app/controller/index.t b/t/app/controller/index.t
index 346ccb2e1..6752d4d7e 100644
--- a/t/app/controller/index.t
+++ b/t/app/controller/index.t
@@ -80,7 +80,24 @@ ok $mech->get('/report/' . $edinburgh_problems[2]->id);
is $mech->res->code, 403, 'page forbidden';
is $problem_rs->count, $num+5;
+my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council', id => 2237);
+subtest "prefilters /around if user has categories" => sub {
+ my $user = $mech->log_in_ok('test@example.com');
+ my $categories = [
+ $mech->create_contact_ok( body_id => $oxon->id, category => 'Cows', email => 'cows@example.net' )->id,
+ $mech->create_contact_ok( body_id => $oxon->id, category => 'Potholes', email => 'potholes@example.net' )->id,
+ ];
+ $user->from_body($oxon);
+ $user->set_extra_metadata('categories', $categories);
+ $user->update;
+
+ $mech->get_ok('/');
+ # NB can't use visible_form_values because categories field is hidden
+ $mech->content_contains("Cows,Potholes");
+};
+
END {
$mech->delete_problems_for_body( 2651 );
+ $mech->delete_body($oxon);
done_testing();
}