aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/index.t
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller/index.t')
-rw-r--r--t/app/controller/index.t33
1 files changed, 27 insertions, 6 deletions
diff --git a/t/app/controller/index.t b/t/app/controller/index.t
index 462b21064..6b28a03d2 100644
--- a/t/app/controller/index.t
+++ b/t/app/controller/index.t
@@ -12,7 +12,6 @@ subtest "check that the form goes to /around" => sub {
$mech->get_ok('/');
is $mech->uri->path, '/', "still on '/'";
- # submit form
$mech->submit_form_ok( { with_fields => { pc => 'SW1A 1AA', } } );
# check that we are at /around
@@ -47,7 +46,11 @@ subtest "does pc, (x,y), (e,n) or (lat,lon) go to /around" => sub {
$uri->query_form( $test->{in} );
# get the uri and check for 302
- $mech->get_ok($uri);
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $mech->get_ok($uri);
+ };
# check that we are at /around
is $mech->uri->path, '/around', "Got to /around";
@@ -55,12 +58,10 @@ subtest "does pc, (x,y), (e,n) or (lat,lon) go to /around" => sub {
}
};
-$mech->delete_problems_for_council( 2651 );
-
my $problem_rs = FixMyStreet::App->model('DB::Problem');
my $num = $problem_rs->count;
-my @edinburgh_problems = $mech->create_problems_for_council(5, 2651, 'Front page');
+my @edinburgh_problems = $mech->create_problems_for_body(5, 2651, 'Front page');
is scalar @edinburgh_problems, 5, 'correct number of edinburgh problems created';
$mech->get_ok('/report/' . $edinburgh_problems[2]->id);
@@ -74,4 +75,24 @@ ok $mech->get('/report/' . $edinburgh_problems[2]->id);
is $mech->res->code, 403, 'page forbidden';
is $problem_rs->count, $num+5;
-done_testing();
+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();
+}