diff options
Diffstat (limited to 't/app/controller')
-rw-r--r-- | t/app/controller/around.t | 6 | ||||
-rw-r--r-- | t/app/controller/report_as_other.t | 17 |
2 files changed, 16 insertions, 7 deletions
diff --git a/t/app/controller/around.t b/t/app/controller/around.t index 3f0fff666..b123692fa 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -228,6 +228,7 @@ subtest 'check category, status and extra filtering works on /around' => sub { # Regression test for filter_category in /around URL FixMyStreet::override_config { + ALLOWED_COBRANDS => 'fixmystreet', MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok( '/around?filter_category=Pothole&bbox=' . $bbox ); @@ -331,15 +332,17 @@ subtest 'check skip_around skips around page' => sub { FixMyStreet::override_config { MAPIT_URL => 'http://mapit.uk/', + MAPIT_TYPES => ['CTY', 'DIS'], }, sub { $mech->get('/around?latitude=51.754926&longitude=-1.256179'); - is $mech->res->code, 302, "around page is a redirect"; + is $mech->res->previous->code, 302, "around page is a redirect"; is $mech->uri->path, '/report/new', "and redirects to /report/new"; }; }; subtest 'check map zoom level customisation' => sub { FixMyStreet::override_config { + ALLOWED_COBRANDS => 'fixmystreet', MAPIT_URL => 'http://mapit.uk/', MAP_TYPE => 'OSM', }, sub { @@ -350,6 +353,7 @@ subtest 'check map zoom level customisation' => sub { FixMyStreet::override_config { + ALLOWED_COBRANDS => 'fixmystreet', MAPIT_URL => 'http://mapit.uk/', MAP_TYPE => 'Tester', }, sub { diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t index 9ed46190b..0c8b7d995 100644 --- a/t/app/controller/report_as_other.t +++ b/t/app/controller/report_as_other.t @@ -16,6 +16,8 @@ my $test_email = 'body-user@example.net'; my $user = $mech->log_in_ok($test_email); $user->update({ from_body => $body->id, name => 'Body User' }); +my $superuser = $mech->create_user_ok('superuser@example.net', name => "Super", is_superuser => 1); + my ($report_to_update) = $mech->create_problems_for_body(1, $body->id, 'Title', { category => 'Potholes' }); subtest "Body user, no permissions, no special reporting tools shown" => sub { @@ -150,10 +152,11 @@ subtest "Body user, has permission to add report as another (existing) user with push @users, $report->user; }; -subtest "Body user, has permission to add report as anonymous user" => sub { +subtest "Superuser, can add report as anonymous user" => sub { FixMyStreet::Script::Reports::send(); $mech->clear_emails_ok; + my $user = $mech->log_in_ok($superuser->email); my $report = add_report( 'contribute_as_anonymous_user', form_as => 'anonymous_user', @@ -161,8 +164,8 @@ subtest "Body user, has permission to add report as anonymous user" => sub { detail => 'Test report details.', category => 'Street lighting', ); - is $report->name, 'Oxfordshire County Council', 'report name is body'; - is $report->user->name, 'Body User', 'user name unchanged'; + is $report->name, 'an administrator', 'report name is admin'; + is $report->user->name, 'Super', 'user name unchanged'; is $report->user->id, $user->id, 'user matches'; is $report->anonymous, 1, 'report anonymous'; @@ -172,12 +175,12 @@ subtest "Body user, has permission to add report as anonymous user" => sub { ); FixMyStreet::Script::Reports::send(); - # No report sent email is sent - $mech->email_count_is(1); my $email = $mech->get_email; like $email->header('Subject'), qr/Problem Report: Test Report/, 'report email title correct'; $mech->clear_emails_ok; $send_confirmation_mail_override->restore(); + + $mech->log_in_ok($test_email); }; subtest "Body user, has permission to add update as council" => sub { @@ -329,7 +332,9 @@ sub add_report { with_fields => \%fields, }, "submit details"); }; - $mech->content_contains('Thank you for reporting this issue'); + # Anonymous test done as superuser, which redirects + $mech->content_contains('Thank you for reporting this issue') + unless $permission eq 'contribute_as_anonymous_user'; my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; ok $report, "Found the report"; is $report->state, 'confirmed', "report is now confirmed"; |