From 15e9a1ab8c399b25bb212a3400c0361a41c9abc6 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Thu, 20 Oct 2016 17:02:45 +0100 Subject: 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 --- t/app/controller/index.t | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 't/app/controller/index.t') 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(); } -- cgit v1.2.3