aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
authorMyfanwy Nixon <myf@mysociety.org>2014-04-10 17:11:58 +0100
committerMatthew Somerville <matthew@mysociety.org>2014-05-16 18:24:22 +0100
commit3687cc573db7fbdae09773d9007bc6abeac89409 (patch)
tree0931cf51030a5bcf55fe7bf9fc07611735d76007 /t/app/controller
parent0d190daf11c8ff29fd53b3a342d0717f5b73da05 (diff)
Update all email templates with new text.
And FixMyStreet.com specific open questionnaire page.
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/alert_new.t131
-rw-r--r--t/app/controller/auth.t2
-rw-r--r--t/app/controller/report_new.t10
-rw-r--r--t/app/controller/report_updates.t6
4 files changed, 132 insertions, 17 deletions
diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t
index 594d4c7a6..14cf32d7c 100644
--- a/t/app/controller/alert_new.t
+++ b/t/app/controller/alert_new.t
@@ -12,7 +12,7 @@ foreach my $test (
email => 'test@example.com',
type => 'area_problems',
content => 'your alert will not be activated',
- email_text => 'confirm the alert',
+ email_text => "confirms that you'd like to receive an email",
uri =>
'/alert/subscribe?type=local&rznvy=test@example.com&feed=area:1000:A_Location',
param1 => 1000
@@ -21,7 +21,7 @@ foreach my $test (
email => 'test@example.com',
type => 'council_problems',
content => 'your alert will not be activated',
- email_text => 'confirm the alert',
+ email_text => "confirms that you'd like to receive an email",
uri =>
'/alert/subscribe?type=local&rznvy=test@example.com&feed=council:1000:A_Location',
param1 => 1000,
@@ -31,7 +31,7 @@ foreach my $test (
email => 'test@example.com',
type => 'ward_problems',
content => 'your alert will not be activated',
- email_text => 'confirm the alert',
+ email_text => "confirms that you'd like to receive an email",
uri =>
'/alert/subscribe?type=local&rznvy=test@example.com&feed=ward:1000:1001:A_Location:Diff_Location',
param1 => 1000,
@@ -41,7 +41,7 @@ foreach my $test (
email => 'test@example.com',
type => 'local_problems',
content => 'your alert will not be activated',
- email_text => 'confirm the alert',
+ email_text => "confirms that you'd like to receive an email",
uri =>
'/alert/subscribe?type=local&rznvy=test@example.com&feed=local:10.2:20.1',
param1 => 20.1,
@@ -51,7 +51,7 @@ foreach my $test (
email => 'test@example.com',
type => 'new_updates',
content => 'your alert will not be activated',
- email_text => 'confirm the alert',
+ email_text => "confirms that you'd like to receive an email",
uri => '/alert/subscribe?type=updates&rznvy=test@example.com&id=1',
param1 => 1,
}
@@ -450,9 +450,9 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
my @emails = $mech->get_email;
my $count;
for (@emails) {
- $count++ if $_->body =~ /The following updates have been left on this problem:/;
- $count++ if $_->body =~ /The following new problems have been reported to City of\s+Edinburgh\s+Council:/;
- $count++ if $_->body =~ /The following nearby problems have been added:/;
+ $count++ if $_->body =~ /The following updates have been left on this report:/;
+ $count++ if $_->body =~ /The following new FixMyStreet reports have been sent to City of\s+Edinburgh\s+Council:/;
+ $count++ if $_->body =~ /The following FixMyStreet reports have been made within the area you\s+specified:/;
$count++ if $_->body =~ /\s+-\s+Testing/;
}
is $count, 5, 'Three emails, with five matching lines in them';
@@ -479,6 +479,121 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
$mech->delete_user($user2);
};
+subtest "Test signature template is used from cobrand" => sub {
+ $mech->delete_user( 'reporter@example.com' );
+ $mech->delete_user( 'alerts@example.com' );
+
+ my $user1 = FixMyStreet::App->model('DB::User')
+ ->find_or_create( { email => 'reporter@example.com', name => 'Reporter User' } );
+ ok $user1, "created test user";
+
+ my $user2 = FixMyStreet::App->model('DB::User')
+ ->find_or_create( { email => 'alerts@example.com', name => 'Alert User' } );
+ ok $user2, "created test user";
+
+ my $dt = DateTime->now()->add( days => 2);
+
+ my $dt_parser = FixMyStreet::App->model('DB')->schema->storage->datetime_parser;
+
+ my $report_time = '2011-03-01 12:00:00';
+ my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( {
+ postcode => 'EH1 1BB',
+ bodies_str => '2651',
+ areas => ',11808,135007,14419,134935,2651,20728,',
+ category => 'Street lighting',
+ title => 'Testing',
+ detail => 'Testing Detail',
+ used_map => 1,
+ name => $user1->name,
+ anonymous => 0,
+ state => 'fixed - user',
+ confirmed => $dt_parser->format_datetime($dt),
+ lastupdate => $dt_parser->format_datetime($dt),
+ whensent => $dt_parser->format_datetime($dt->clone->add( minutes => 5 )),
+ lang => 'en-gb',
+ service => '',
+ cobrand => 'default',
+ cobrand_data => '',
+ send_questionnaire => 1,
+ latitude => '55.951963',
+ longitude => '-3.189944',
+ user_id => $user1->id,
+ } );
+ my $report_id = $report->id;
+ ok $report, "created test report - $report_id";
+
+ my $alert = FixMyStreet::App->model('DB::Alert')->create( {
+ parameter => $report_id,
+ alert_type => 'new_updates',
+ user => $user1,
+ cobrand => 'default',
+ } );
+ my $ret = $alert->confirm;
+ ok $ret, 'created alert for reporter';
+
+ my $update = FixMyStreet::App->model('DB::Comment')->create( {
+ problem_id => $report_id,
+ user_id => $user2->id,
+ name => 'Other User',
+ mark_fixed => 'false',
+ text => 'This is some update text',
+ state => 'confirmed',
+ confirmed => $dt->clone->add( hours => 7 ),
+ anonymous => 'f',
+ } );
+ my $update_id = $update->id;
+ ok $update, "created test update - $update_id";
+
+
+ $mech->clear_emails_ok;
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ }, sub {
+ 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(1);
+
+ my @emails = $mech->get_email;
+ my $email = $emails[0];
+ like $email->body, qr/All the best/, 'default signature used';
+ unlike $email->body, qr/twitter.com/, 'nothing from fixmystreet signature';
+
+ $update = FixMyStreet::App->model('DB::Comment')->create( {
+ problem_id => $report_id,
+ user_id => $user2->id,
+ name => 'Anonymous User',
+ mark_fixed => 'true',
+ text => 'This is some more update text',
+ state => 'confirmed',
+ confirmed => $dt->clone->add( hours => 8 ),
+ anonymous => 't',
+ } );
+ $update_id = $update->id;
+ ok $update, "created test update - $update_id";
+
+ $alert->cobrand('fixmystreet');
+ $alert->update;
+
+ $mech->clear_emails_ok;
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ }, sub {
+ 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(1);
+
+ @emails = $mech->get_email;
+ $email = $emails[0];
+ like $email->body, qr/twitter.com/, 'fixmystreet signature used';
+
+ $mech->delete_user($user1);
+ $mech->delete_user($user2);
+};
+
for my $test (
{
desc => 'check non public reports are not included in council problems alerts',
diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t
index 3d52c0925..17ba0d1a0 100644
--- a/t/app/controller/auth.t
+++ b/t/app/controller/auth.t
@@ -66,7 +66,7 @@ $mech->not_logged_in_ok;
$mech->email_count_is(1);
my $email = $mech->get_email;
$mech->clear_emails_ok;
- is $email->header('Subject'), "Your FixMyStreet.com account details",
+ is $email->header('Subject'), "Your FixMyStreet account details",
"subject is correct";
is $email->header('To'), $test_email, "to is correct";
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 98b0175f8..157d63d01 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -587,7 +587,7 @@ foreach my $test (
# receive token
my $email = $mech->get_email;
ok $email, "got an email";
- like $email->body, qr/confirm the problem/i, "confirm the problem";
+ like $email->body, qr/confirm that you want to send your\s+report/i, "confirm the problem";
my ($url) = $email->body =~ m{(http://\S+)};
ok $url, "extracted confirm url '$url'";
@@ -932,7 +932,7 @@ subtest "test report creation for a category that is non public" => sub {
my $email = $mech->get_email;
ok $email, "got an email";
- like $email->body, qr/confirm the problem/i, "confirm the problem";
+ like $email->body, qr/confirm that you want to send your\s+report/i, "confirm the problem";
my ($url) = $email->body =~ m{(http://\S+)};
ok $url, "extracted confirm url '$url'";
@@ -1128,7 +1128,7 @@ for my $test (
my $email = $mech->get_email;
ok $email, "got an email";
- like $email->body, qr/confirm the problem/i, "confirm the problem";
+ like $email->body, qr/confirm that you want to send your\s+report/i, "confirm the problem";
my ($url) = $email->body =~ m{(https?://\S+)};
ok $url, "extracted confirm url '$url'";
@@ -1298,7 +1298,7 @@ subtest "test Lichfield" => sub {
# receive token
my $email = $mech->get_email;
ok $email, "got an email";
- like $email->body, qr/confirm the problem/i, "confirm the problem";
+ like $email->body, qr/to confirm that you want to send your/i, "confirm the problem";
my ($url) = $email->body =~ m{(http://\S+)};
ok $url, "extracted confirm url '$url'";
@@ -1576,7 +1576,7 @@ subtest "extra google analytics code displayed on email confirmation problem cre
my $email = $mech->get_email;
ok $email, "got an email";
- like $email->body, qr/confirm the problem/i, "confirm the problem";
+ like $email->body, qr/confirm that you want to/i, "confirm the problem";
my ($url) = $email->body =~ m{(https?://\S+)};
ok $url, "extracted confirm url '$url'";
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index e84755650..17947a212 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -355,7 +355,7 @@ for my $test (
my $email = $mech->get_email;
ok $email, "got an email";
- like $email->body, qr/confirm the update you/i, "Correct email text";
+ like $email->body, qr/confirm your update on/i, "Correct email text";
my ( $url, $url_token ) = $email->body =~ m{(http://\S+/C/)(\S+)};
ok $url, "extracted confirm url '$url'";
@@ -1010,7 +1010,7 @@ subtest 'submit an update for a registered user, creating update by email' => su
my $email = $mech->get_email;
ok $email, "got an email";
- like $email->body, qr/confirm the update you/i, "Correct email text";
+ like $email->body, qr/confirm your update on/i, "Correct email text";
my ( $url, $url_token ) = $email->body =~ m{(http://\S+/C/)(\S+)};
ok $url, "extracted confirm url '$url'";
@@ -1513,7 +1513,7 @@ for my $test (
my $email = $mech->get_email;
ok $email, "got an email";
- like $email->body, qr/confirm the update you/i, "Correct email text";
+ like $email->body, qr/confirm your update on/i, "Correct email text";
my ( $url, $url_token ) = $email->body =~ m{(http://\S+/C/)(\S+)};
ok $url, "extracted confirm url '$url'";