diff options
Diffstat (limited to 't/app')
-rw-r--r-- | t/app/controller/around.t | 16 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 45 |
2 files changed, 61 insertions, 0 deletions
diff --git a/t/app/controller/around.t b/t/app/controller/around.t index 8b4fc7825..d1254edb7 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -1,3 +1,5 @@ +use Test::MockModule; + use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -174,4 +176,18 @@ subtest 'check category and status filtering works on /around?ajax' => sub { is scalar @$pins, 1, 'correct number of fixed Vegetation reports'; }; +subtest 'check skip_around skips around page' => sub { + my $cobrand = Test::MockModule->new('FixMyStreet::Cobrand::Default'); + $cobrand->mock('skip_around_page', sub { 1 }); + $cobrand->mock('country', sub { 1 }); + + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->get('/around?latitude=51.754926&longitude=-1.256179'); + is $mech->res->code, 302, "around page is a redirect"; + is $mech->uri->path, '/report/new', "and redirects to /report/new"; + }; +}; + done_testing(); diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index f741ec796..e0fe205bd 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -1056,6 +1056,51 @@ subtest "check that a lat/lon off coast leads to /around" => sub { }; +subtest "check we load a partial report correctly" => sub { + my $user = FixMyStreet::App->model('DB::User')->find_or_create( + { + email => 'test-partial@example.com' + } + ); + + my $report = FixMyStreet::App->model('DB::Problem')->create( { + name => '', + postcode => '', + category => 'Street lighting', + title => 'Testing', + detail => "Testing Detail", + anonymous => 0, + state => 'partial', + lang => 'en-gb', + service => '', + areas => '', + used_map => 1, + latitude => '51.754926', + longitude => '-1.256179', + user_id => $user->id, + } ); + + my $report_id = $report->id; + + my $token = FixMyStreet::App->model("DB::Token") + ->create( { scope => 'partial', data => $report->id } ); + + my $token_code = $token->token; + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], + MAPIT_URL => 'http://mapit.uk/', + }, + sub { + $mech->get("/L/$token_code"); + is $mech->res->previous->code, 302, 'partial token page redirects'; + is $mech->uri->path, "/report/new", "partial redirects to report page"; + $mech->content_contains('Testing Detail'); + }; + + $mech->delete_user($user); +}; + for my $test ( { desc => 'user title not set if not bromley problem', |