aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-10-12 18:00:44 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-10-12 18:00:50 +0100
commit9606353b3d3fb3be9e6b1d25dda154a7fdc33b10 (patch)
tree7f1dc9295198d183af63e87852e8cb60b6614512 /t/app/controller
parentc4bc439991b5edbe4b177c07d7e9f99bbffb34e1 (diff)
If update alert email is to problem reporter, make it a login link.
This is so they can more easily update, especially if the update they've just received has mistakingly 'fixed' the report. This fixes #7.
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/alert_new.t18
1 files changed, 14 insertions, 4 deletions
diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t
index cb787d959..c89f37028 100644
--- a/t/app/controller/alert_new.t
+++ b/t/app/controller/alert_new.t
@@ -390,7 +390,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
used_map => 1,
name => $user1->name,
anonymous => 0,
- state => 'confirmed',
+ state => 'fixed - user',
confirmed => $dt,
lastupdate => $dt,
whensent => $dt->clone->add( minutes => 5 ),
@@ -430,7 +430,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
problem_id => $report_id,
user_id => $user2->id,
name => 'Anonymous User',
- mark_fixed => 'false',
+ mark_fixed => 'true',
text => 'This is some more update text',
state => 'confirmed',
confirmed => $dt->clone->add( hours => 8 ),
@@ -450,13 +450,23 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
$count++ if $_->body =~ /The following nearby problems have been added:/;
$count++ if $_->body =~ /\s+-\s+Testing/;
}
- is $count, 5, 'Five emails with the right things in them';
+ is $count, 5, 'Three emails, with five matching lines in them';
my $email = $emails[0];
like $email->body, qr/Other User/, 'Update name given';
unlike $email->body, qr/Anonymous User/, 'Update name not given';
- my ( $url, $url_token ) = $emails[0]->body =~ m{http://\S+(/A/(\S+))};
+ # The update alert was to the problem reporter, so has a login update URL
+ $mech->get_ok( "/report/$report_id" );
+ $mech->content_lacks( 'has not been fixed' );
+ my ($url) = $email->body =~ m{(http://\S+/M/\S+)};
+ ok $url, "extracted update url '$url'";
+ $mech->get_ok( $url );
+ is $mech->uri->path, "/report/" . $report_id, "redirected to report page";
+ $mech->content_contains( 'has not been fixed' );
+ $mech->logged_in_ok;
+
+ ($url) = $emails[0]->body =~ m{http://\S+(/A/\S+)};
$mech->get_ok( $url );
$mech->content_contains('successfully deleted');