aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/alert_new.t
diff options
context:
space:
mode:
authorDave Whiteland <dave@mysociety.org>2012-05-29 15:57:41 +0100
committerDave Whiteland <dave@mysociety.org>2012-05-29 15:57:41 +0100
commit67da8efc720d2d0bd22bd9fe8655b7e983b35bb4 (patch)
tree38b8570647124df06c637d4b923f6010211ef328 /t/app/controller/alert_new.t
parent40b3a51d33caefa8f5fb97ce9be18ef936c7e260 (diff)
parent131ff6e9bf3626d6a8fff6ae54669d250148a63a (diff)
Merge remote branch 'origin/master' into fmb-read-only
Conflicts: bin/send-reports perllib/FixMyStreet/Cobrand/Default.pm perllib/FixMyStreet/Cobrand/FixMyStreet.pm templates/web/fixmystreet/alert/index.html templates/web/fixmystreet/around/display_location.html web/cobrands/fixmystreet/_layout.scss web/js/map-OpenLayers.js
Diffstat (limited to 't/app/controller/alert_new.t')
-rw-r--r--t/app/controller/alert_new.t32
1 files changed, 14 insertions, 18 deletions
diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t
index 3a4c2ef81..7ba887824 100644
--- a/t/app/controller/alert_new.t
+++ b/t/app/controller/alert_new.t
@@ -142,25 +142,18 @@ foreach my $test (
}
foreach my $test (
- {
- email => 'test-new@example.com',
- type => 'area',
- content => 'your alert will not be activated',
- email_text => 'confirm the alert',
- uri =>
-'/alert/subscribe?type=local&rznvy=test-new@example.com&feed=area:1000:A_Location',
- param1 => 1000
- }
+ { exist => 0 },
+ { exist => 1 },
)
{
- subtest "use existing unlogged in user in a alert" => sub {
+ subtest "use existing unlogged in user in a alert ($test->{exist})" => sub {
$mech->log_out_ok();
- my $type = $test->{type} . '_problems';
+ my $type = 'area_problems';
my $user =
FixMyStreet::App->model('DB::User')
- ->find_or_create( { email => $test->{email} } );
+ ->find_or_create( { email => 'test-new@example.com' } );
my $alert = FixMyStreet::App->model('DB::Alert')->find(
{
@@ -169,24 +162,26 @@ foreach my $test (
}
);
# clear existing data so we can be sure we're creating it
- ok $alert->delete() if $alert;
+ ok $alert->delete() if $alert && !$test->{exist};
- $mech->get_ok( $test->{uri} );
+ $mech->get_ok( '/alert/subscribe?type=local&rznvy=test-new@example.com&feed=area:1000:A_Location' );
$alert = FixMyStreet::App->model('DB::Alert')->find(
{
user => $user,
alert_type => $type,
- parameter => $test->{param1},
- parameter2 => $test->{param2},
- confirmed => 0,
+ parameter => 1000,
+ parameter2 => undef,
+ confirmed => $test->{exist},
}
);
$mech->content_contains( 'Now check your email' );
+ $alert->confirm();
ok $alert, 'New alert created with existing user';
- $mech->delete_user($user);
+
+ $mech->delete_user($user) if $test->{exist};
};
}
@@ -445,6 +440,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
ok $update, "created test update - $update_id";
FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ # TODO Note the below will fail if the db has an existing alert that matches
$mech->email_count_is(3);
my @emails = $mech->get_email;
my $count;