diff options
author | Struan Donald <struan@exo.org.uk> | 2011-05-10 16:16:02 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-05-10 16:16:02 +0100 |
commit | a1fa6aa37ce73e2a637e4bac565cd0a199f551e2 (patch) | |
tree | 1bec2af2099d9f132c2839a3ead425c9456fcba1 /t/app/controller/alert_new.t | |
parent | 8a42c29b7d80521325163d319d91d96d4a418887 (diff) |
local alert email signup
Diffstat (limited to 't/app/controller/alert_new.t')
-rw-r--r-- | t/app/controller/alert_new.t | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t new file mode 100644 index 000000000..3d1bfeabf --- /dev/null +++ b/t/app/controller/alert_new.t @@ -0,0 +1,83 @@ +use strict; +use warnings; +use Test::More; + + +use FixMyStreet::TestMech; + +my $mech = FixMyStreet::TestMech->new; + +foreach my $test ( + { + email => 'test@example.com', + type => 'area', + content => 'your alert will not be activated', + email_text => 'confirm the alert', + uri => + '/alert/subscribe?type=local&rznvy=test@example.com&feed=area:1000:A_Location', + param1 => 1000 + }, + { + email => 'test@example.com', + type => 'council', + content => 'your alert will not be activated', + email_text => 'confirm the alert', + uri => + '/alert/subscribe?type=local&rznvy=test@example.com&feed=council:1000:A_Location', + param1 => 1000, + param2 => 1000, + }, + { + email => 'test@example.com', + type => 'ward', + content => 'your alert will not be activated', + email_text => 'confirm the alert', + uri => + '/alert/subscribe?type=local&rznvy=test@example.com&feed=ward:1000:1001:A_Location:Diff_Location', + param1 => 1000, + param2 => 1001, + }, + { + email => 'test@example.com', + type => 'local', + content => 'your alert will not be activated', + email_text => 'confirm the alert', + uri => + '/alert/subscribe?type=local&rznvy=test@example.com&feed=local:10.2:20.1', + param1 => 10.2, + param2 => 20.1, + } +) { + subtest "$test->{type} alert correctly created" => sub { + $mech->clear_emails_ok; + + my $type = $test->{type} . '_problems'; + + # we don't want an alert + my $alert = FixMyStreet::App->model('DB::Alert')->find( { email => + $test->{email}, alert_type => $type } ); + $alert->delete() if $alert; + + $mech->get_ok($test->{uri}); + $mech->content_contains($test->{content}); + + $alert = FixMyStreet::App->model('DB::Alert')->find( { email => + $test->{email}, alert_type => $type, parameter => + $test->{param1}, parameter2 => $test->{param2} } ); + + ok $alert, "Found the alert"; + + SKIP: { + skip 'sending email not yet implemented', 4; + + my $email = $mech->get_email; + ok $email, "got an email"; + like $email->body, qr/$test->{email_text}/i, "Correct email text"; + + my ($url) = $email->body =~ m{(http://\S+)}; + ok $url, "extracted confirm url '$url'"; + }; + }; +} + +done_testing(); |