diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-08-10 17:31:57 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-08-10 17:54:12 +0100 |
commit | e789a07dcb1936e3b0d7a23583aaf3d05e3d80f5 (patch) | |
tree | fd433cd0a2704eff202f464b95a0f1e190c99154 | |
parent | 4faf6b08b07bf450d87db10df786f2b7ff8a802c (diff) |
Direct report moderated emails correctly.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Moderate.pm | 10 | ||||
-rw-r--r-- | t/app/controller/moderate.t | 14 |
2 files changed, 12 insertions, 12 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Moderate.pm b/perllib/FixMyStreet/App/Controller/Moderate.pm index 2d23417b9..dadec5c53 100644 --- a/perllib/FixMyStreet/App/Controller/Moderate.pm +++ b/perllib/FixMyStreet/App/Controller/Moderate.pm @@ -28,8 +28,7 @@ data to change. The original data of the report is stored in moderation_original_data, so that it can be reverted/consulted if required. All moderation events are -stored in moderation_log. (NB: In future, this could be combined with -admin_log). +stored in admin_log. =head1 SEE ALSO @@ -102,18 +101,15 @@ sub report_moderate_audit : Private { reason => (sprintf '%s (%s)', $reason, $types_csv), }); - my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($problem->cobrand)->new(); - my $token = $c->model("DB::Token")->create({ scope => 'moderation', data => { id => $problem->id } }); $c->send_email( 'problem-moderated.txt', { - - to => [ [ $user->email, $user->name ] ], + to => [ [ $problem->user->email, $problem->name ] ], types => $types_csv, - user => $user, + user => $problem->user, problem => $problem, report_uri => $c->stash->{report_uri}, report_complain_uri => $c->stash->{cobrand_base} . '/contact?m=' . $token->token, diff --git a/t/app/controller/moderate.t b/t/app/controller/moderate.t index e3e8bf2cf..52201c63b 100644 --- a/t/app/controller/moderate.t +++ b/t/app/controller/moderate.t @@ -19,6 +19,8 @@ my $user = $mech->create_user_ok('test-moderation@example.com', name => 'Test Us $user->user_body_permissions->delete_all; $user->discard_changes; +my $user2 = $mech->create_user_ok('test-moderation2@example.com', name => 'Test User 2'); + sub create_report { FixMyStreet::App->model('DB::Problem')->create( { @@ -29,7 +31,7 @@ sub create_report { title => 'Good bad good', detail => 'Good bad bad bad good bad', used_map => 't', - name => 'Test User', + name => 'Test User 2', anonymous => 'f', state => 'confirmed', confirmed => $dt->ymd . ' ' . $dt->hms, @@ -40,7 +42,7 @@ sub create_report { send_questionnaire => 't', latitude => '51.4129', longitude => '0.007831', - user_id => $user->id, + user_id => $user2->id, photo => $mech->get_photo_data, }); } @@ -169,7 +171,9 @@ subtest 'Problem moderation' => sub { $report->discard_changes; is $report->state, 'hidden', 'Is hidden'; - my $url = $mech->get_link_from_email; + my $email = $mech->get_email; + is $email->header('To'), '"Test User 2" <test-moderation2@example.com>', 'Sent to correct email'; + my $url = $mech->get_link_from_email($email); ok $url, "extracted complain url '$url'"; $mech->get_ok($url); @@ -210,8 +214,8 @@ subtest 'Problem 2' => sub { sub create_update { $report->comments->create({ - user => $user, - name => 'Test User', + user => $user2, + name => 'Test User 2', anonymous => 'f', photo => $mech->get_photo_data, text => 'update good good bad good', |