From 0a38fbfb7d21e0e9c79a747b17c7f4058c791e06 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 10 May 2011 17:32:58 +0100 Subject: test that we do not duplicate existing alerts --- t/app/controller/alert_new.t | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 't/app/controller/alert_new.t') diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t index 72467d31c..8ee9d071b 100644 --- a/t/app/controller/alert_new.t +++ b/t/app/controller/alert_new.t @@ -91,6 +91,29 @@ foreach my $test ( ); ok $token, 'Token found in database'; ok $alert->id == $token->data->{id}, 'token alertid matches alert id'; + + $mech->clear_emails_ok; + + my $existing_id = $alert->id; + my $existing_token = $url_token; + + $mech->get_ok( $test->{uri} ); + + $email = $mech->get_email; + ok $email, 'got a second email'; + + ($url_token) = $email->body =~ m{http://\S+/A/(\S+)}; + ok $url_token ne $existing_token, 'sent out a new token'; + + $token = FixMyStreet::App->model('DB::Token')->find( + { + token => $url_token, + scope => 'alert' + } + ); + + ok $token, 'new token found in database'; + ok $token->data->{id} == $existing_id, 'subscribed to exsiting alert'; }; } -- cgit v1.2.3