diff options
author | Zarino Zappia <mail@zarino.co.uk> | 2019-08-20 11:16:53 +0100 |
---|---|---|
committer | Zarino Zappia <mail@zarino.co.uk> | 2019-08-23 10:38:29 +0100 |
commit | 3c4d48f5fd5f499736f07ac2a5d17c1d4bab6c14 (patch) | |
tree | 59df44c764e803c679c01f17296a01fdb7813619 /t/app/controller | |
parent | 169c8960d9c32e35f5a2603c611857757d8b1044 (diff) |
Include user admin links in contact form emails
If a message is sent via the contact form, with a stated email address
matching a user in the database, the resulting email will now include
quick links to:
- Admin page for editing the user
- Admin page for viewing the user’s reports
And if the user has made at least one report, also:
- Admin page for the user’s most recent report
This should speed up admin email triage considerably.
Diffstat (limited to 't/app/controller')
-rw-r--r-- | t/app/controller/contact.t | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t index c74aaa5ff..908ec971b 100644 --- a/t/app/controller/contact.t +++ b/t/app/controller/contact.t @@ -337,6 +337,70 @@ for my $test ( } for my $test ( + { fields => \%common } + ) +{ + subtest 'check email contains user details' => sub { + my $user = $mech->create_user_ok( + $test->{fields}->{em}, + name => $test->{fields}->{name} + ); + + my $older_unhidden_problem = FixMyStreet::App->model('DB::Problem')->create( + { + title => 'Some problem or other', + detail => 'More detail on the problem', + postcode => 'EH99 1SP', + confirmed => '2011-05-04 10:44:28.145168', + anonymous => 0, + name => $test->{fields}->{name}, + state => 'confirmed', + user => $user, + latitude => 0, + longitude => 0, + areas => 0, + used_map => 0, + } + ); + + my $newer_hidden_problem = FixMyStreet::App->model('DB::Problem')->create( + { + title => 'A hidden problem', + detail => 'Shhhh secret', + postcode => 'EH99 1SP', + confirmed => '2012-06-05 10:44:28.145168', + anonymous => 0, + name => $test->{fields}->{name}, + state => 'hidden', + user => $user, + latitude => 0, + longitude => 0, + areas => 0, + used_map => 0, + } + ); + + $mech->clear_emails_ok; + $mech->get_ok('/contact'); + $mech->submit_form_ok( { with_fields => $test->{fields} } ); + + my $email = $mech->get_email; + my $body = $mech->get_text_body_from_email($email); + + my $user_id = $user->id; + my $user_email = $user->email; + my $older_unhidden_problem_id = $older_unhidden_problem->id; + my $newer_hidden_problem_id = $newer_hidden_problem->id; + + like $body, qr/admin\/users\/$user_id/, 'email contains admin link to edit user'; + like $body, qr/admin\/reports\?search=$user_email/, 'email contains admin link to show users reports'; + like $body, qr/admin\/report_edit\/$older_unhidden_problem_id/, 'email contains admin link for users latest unhidden report'; + unlike $body, qr/admin\/report_edit\/$newer_hidden_problem_id/, 'email does not link to hidden reports'; + + }; +} + +for my $test ( { fields => { %common, dest => undef }, page_errors => |