aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Alert.pm10
-rw-r--r--t/app/controller/alert_new.t9
-rw-r--r--templates/web/default/alert/confirm.html2
3 files changed, 16 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm
index 7ea0d77e3..b836f5a79 100644
--- a/perllib/FixMyStreet/App/Controller/Alert.pm
+++ b/perllib/FixMyStreet/App/Controller/Alert.pm
@@ -140,7 +140,12 @@ sub subscribe_email : Private {
}
$c->forward('create_alert');
- $c->forward('send_confirmation_email');
+ if ( $c->stash->{alert}->confirmed ) {
+ $c->stash->{confirm_type} = 'created';
+ $c->stash->{template} = 'alert/confirm.html';
+ } else {
+ $c->forward('send_confirmation_email');
+ }
}
sub updates : Path('updates') : Args(0) {
@@ -190,14 +195,13 @@ sub create_alert : Private {
unless ($alert) {
$options->{cobrand} = $c->cobrand->moniker();
$options->{cobrand_data} = $c->cobrand->extra_update_data();
+ $options->{confirmed} = 1 if $c->stash->{alert_user}->in_storage;
$alert = $c->model('DB::Alert')->new($options);
$alert->insert();
}
$c->stash->{alert} = $alert;
-
- $c->log->debug( 'created alert ' . $alert->id );
}
=head2 set_update_alert_options
diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t
index 7cbf6188a..4b23cb950 100644
--- a/t/app/controller/alert_new.t
+++ b/t/app/controller/alert_new.t
@@ -181,7 +181,7 @@ foreach my $test (
alert_type => $type,
parameter => $test->{param1},
parameter2 => $test->{param2},
- confirmed => 0,
+ confirmed => 1,
}
);
@@ -209,6 +209,8 @@ foreach my $test (
$mech->log_in_ok( $test->{email} );
+ $mech->clear_emails_ok;
+
my $alert;
if ($user) {
$alert = FixMyStreet::App->model('DB::Alert')->find(
@@ -237,11 +239,14 @@ foreach my $test (
alert_type => $type,
parameter => $test->{param1},
parameter2 => $test->{param2},
- confirmed => 0,
+ confirmed => 1,
}
);
ok $alert, 'New alert created with existing user';
+
+ $mech->email_count_is(0);
+
};
}
diff --git a/templates/web/default/alert/confirm.html b/templates/web/default/alert/confirm.html
index 3dc4bed97..07694cbb6 100644
--- a/templates/web/default/alert/confirm.html
+++ b/templates/web/default/alert/confirm.html
@@ -7,6 +7,8 @@
[% loc('You have successfully confirmed your alert.') %]
[% ELSIF confirm_type == 'unsubscribe' %]
[% loc('You have successfully deleted your alert.') %]
+[% ELSIF confirm_type == 'created' %]
+ [% loc('You have successfully created your alert.') %]
[% END %]
</p>