diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 14 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 4 |
2 files changed, 14 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 691a4ecc9..d9136698d 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -249,15 +249,23 @@ sub redirect_or_confirm_creation : Private { } # otherwise create a confirm token and email it to them. - my $token = - $c->model("DB::Token") - ->create( { scope => 'comment', data => $update->id } ); + my $token = $c->model("DB::Token")->create( + { + scope => 'comment', + data => { + id => $update->id, + add_alert => ( $c->req->param('add_alert') ? 1 : 0 ), + } + } + ); $c->stash->{token_url} = $c->uri_for_email( '/C', $token->token ); $c->send_email( 'update-confirm.txt', { to => $update->user->email } ); # tell user that they've been sent an email $c->stash->{template} = 'email_sent.html'; $c->stash->{email_type} = 'update'; + + return 1; } __PACKAGE__->meta->make_immutable; diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index e64e2f4d6..8f64f1109 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -249,7 +249,8 @@ subtest "submit an update for a non registered user" => sub { ); ok $token, 'Token found in database'; - my $update_id = $token->data; + my $update_id = $token->data->{id}; + my $add_alerts = $token->data->{add_alert}; my $update = FixMyStreet::App->model( 'DB::Comment' )->find( { id => $update_id } ); @@ -258,6 +259,7 @@ subtest "submit an update for a non registered user" => sub { is $update->state, 'unconfirmed', 'update unconfirmed'; is $update->user->email, 'unregistered@example.com', 'update email'; is $update->text, 'update from an unregistered user', 'update text'; + is $add_alerts, 0, 'do not sign up for alerts'; }; subtest "submit an update for a registered user" => sub { |