diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-04-05 13:43:29 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-04-05 13:43:29 +0100 |
commit | 9195de2a66ce7ff898a76040a1704a8185b5d5d5 (patch) | |
tree | 32cf33c5214fe4ab93c870e42a3786711d8d1f18 /t | |
parent | bcfd55500b9e4546a3951079285e85d2e9cf4995 (diff) | |
parent | 3a02f5e91bca03cbe9cbc29bcea5a1df7499eadb (diff) |
Merge branch '2435-admin-anonymous-report'
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/report_as_other.t | 17 |
1 files changed, 11 insertions, 6 deletions
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"; |