aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm11
-rw-r--r--t/app/controller/report_as_other.t26
3 files changed, 26 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6ae350b1a..102f77413 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,6 +30,7 @@
- Add optional enforced password expiry.
- Store a moderation history on admin report edit.
- Add user admin log page.
+ - Allow report as another user with only name.
- New features:
- Categories can be listed under more than one group #2475
- OpenID Connect login support. #2523
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index db469f130..650881da3 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -838,9 +838,11 @@ sub process_user : Private {
my $user = $c->user->obj;
if ($c->stash->{contributing_as_another_user}) {
- # Act as if not logged in (and it will be auto-confirmed later on)
- $report->user(undef);
- last;
+ if ($params{username} || $params{phone}) {
+ # Act as if not logged in (and it will be auto-confirmed later on)
+ $report->user(undef);
+ last;
+ }
}
$report->user( $user );
@@ -854,6 +856,8 @@ sub process_user : Private {
$report->name($name);
$user->name($name) unless $user->name;
$c->stash->{no_reporter_alert} = 1;
+ } elsif ($c->stash->{contributing_as_another_user}) {
+ $c->stash->{no_reporter_alert} = 1;
}
return 1;
@@ -1595,6 +1599,7 @@ sub redirect_or_confirm_creation : Private {
# Subscribe problem reporter to email updates
$c->forward( 'create_reporter_alert' );
if ($c->stash->{contributing_as_another_user} && $report->user->email
+ && $report->user->id != $c->user->id
&& !$c->cobrand->report_sent_confirmation_email) {
$c->send_email( 'other-reported.txt', {
to => [ [ $report->user->email, $report->name ] ],
diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t
index a07a903ff..377de27bd 100644
--- a/t/app/controller/report_as_other.t
+++ b/t/app/controller/report_as_other.t
@@ -40,7 +40,6 @@ subtest "Body user, has permission to add report as council" => sub {
is $report->anonymous, 0, 'report not anonymous';
};
-my @users;
subtest "Body user, has permission to add report as another user with email" => sub {
my $report = add_report(
'contribute_as_another_user',
@@ -56,7 +55,6 @@ subtest "Body user, has permission to add report as another user with email" =>
is $report->user->email, 'another@example.net', 'user email correct';
isnt $report->user->id, $user->id, 'user does not match';
like $mech->get_text_body_from_email, qr/Your report to Oxfordshire County Council has been logged/;
- push @users, $report->user;
};
subtest "Body user, has permission to add report as another user with mobile phone number" => sub {
@@ -77,7 +75,6 @@ subtest "Body user, has permission to add report as another user with mobile pho
is $report->user->email_verified, 0, 'user email not verified';
isnt $report->user->id, $user->id, 'user does not match';
$mech->email_count_is(0);
- push @users, $report->user;
};
subtest "Body user, has permission to add report as another user with landline number" => sub {
@@ -98,7 +95,23 @@ subtest "Body user, has permission to add report as another user with landline n
is $report->user->email_verified, 0, 'user email not verified';
isnt $report->user->id, $user->id, 'user does not match';
$mech->email_count_is(0);
- push @users, $report->user;
+};
+
+subtest "Body user, has permission to add report as another user with only name" => sub {
+ my $report = add_report(
+ 'contribute_as_another_user',
+ form_as => 'another_user',
+ title => "Test Report",
+ detail => 'Test report details.',
+ category => 'Potholes',
+ name => 'Another User',
+ username => '',
+ may_show_name => undef,
+ );
+ is $report->name, 'Another User', 'report name is name given';
+ is $report->user->name, 'Body User', 'user name unchanged';
+ is $report->user->id, $user->id, 'user matches';
+ is $report->anonymous, 1, 'report anonymous';
};
subtest "Body user, has permission to add report as another (existing) user with email" => sub {
@@ -120,7 +133,6 @@ subtest "Body user, has permission to add report as another (existing) user with
is $report->user->email, $existing->email, 'user email correct';
isnt $report->user->id, $user->id, 'user does not match';
like $mech->get_text_body_from_email, qr/Your report to Oxfordshire County Council has been logged/;
- push @users, $report->user;
my $send_confirmation_mail_override = Sub::Override->new(
"FixMyStreet::Cobrand::Default::report_sent_confirmation_email",
@@ -148,7 +160,6 @@ subtest "Body user, has permission to add report as another (existing) user with
is $report->user->phone, '+447906333333', 'user phone correct';
isnt $report->user->id, $user->id, 'user does not match';
$mech->email_count_is(0);
- push @users, $report->user;
};
subtest "Superuser, can add report as anonymous user" => sub {
@@ -231,7 +242,6 @@ subtest "Body user, has permission to add update as another user with email" =>
is $update->user->email, 'another2@example.net', 'user email correct';
isnt $update->user->id, $user->id, 'user does not match';
like $mech->get_text_body_from_email, qr/Your update has been logged/;
- push @users, $update->user;
};
subtest "Body user, has permission to add update as another user with mobile phone" => sub {
@@ -247,7 +257,6 @@ subtest "Body user, has permission to add update as another user with mobile pho
is $update->user->phone, '+447906444444', 'user phone correct';
isnt $update->user->id, $user->id, 'user does not match';
$mech->email_count_is(0);
- push @users, $update->user;
};
subtest "Body user, has permission to add update as another user with landline phone" => sub {
@@ -263,7 +272,6 @@ subtest "Body user, has permission to add update as another user with landline p
is $update->user->phone, '+441685555555', 'user phone correct';
isnt $update->user->id, $user->id, 'user does not match';
$mech->email_count_is(0);
- push @users, $update->user;
};
subtest "Body user, has permission to add update as another (existing) user with email" => sub {