aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-03-29 12:00:35 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-04-05 12:30:28 +0100
commit3a02f5e91bca03cbe9cbc29bcea5a1df7499eadb (patch)
treec025a9091fac8b4c6a8ae42b4ff7ab1aa0fb1542 /t
parent8ca5583e62b1c24128b8d691a8b5f5236ce99eef (diff)
Fix superusers creating anonymous reports.
Diffstat (limited to 't')
-rw-r--r--t/app/controller/report_as_other.t17
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";