aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/model
diff options
context:
space:
mode:
Diffstat (limited to 't/app/model')
-rw-r--r--t/app/model/alert_type.t47
-rw-r--r--t/app/model/problem.t8
2 files changed, 36 insertions, 19 deletions
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t
index 7df4c44c0..c592e9d3f 100644
--- a/t/app/model/alert_type.t
+++ b/t/app/model/alert_type.t
@@ -22,6 +22,10 @@ my $user2 =
->find_or_create( { email => 'commenter@example.com', name => 'Commenter' } );
ok $user2, "created comment user";
+my $user3 =
+ FixMyStreet::App->model('DB::User')
+ ->find_or_create( { email => 'bystander@example.com', name => 'Bystander' } );
+ok $user3, "created bystander";
my $dt = DateTime->new(
year => 2011,
@@ -96,6 +100,16 @@ my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
}
);
+my $alert3 = FixMyStreet::App->model('DB::Alert')->find_or_create(
+ {
+ user => $user3,
+ parameter => $report_id,
+ alert_type => 'new_updates',
+ whensubscribed => $dt->ymd . ' ' . $dt->hms,
+ confirmed => 1,
+ }
+);
+
for my $test (
{
state => 'closed',
@@ -115,7 +129,7 @@ for my $test (
my $sent = FixMyStreet::App->model('DB::AlertSent')->search(
{
- alert_id => $alert->id,
+ alert_id => [ $alert->id, $alert3->id ],
parameter => $comment->id,
}
)->delete;
@@ -125,18 +139,25 @@ for my $test (
FixMyStreet::App->model('DB::AlertType')->email_alerts();
- $mech->email_count_is( 1 );
- my $email = $mech->get_email;
+ $mech->email_count_is( 2 );
+ my @emails = $mech->get_email;
my $msg = $test->{msg};
- my $body = $email->body;
-
- like $body, qr/$msg/, 'email says problem is ' . $test->{state};
- like $body, qr{report/$report_id}, 'contains problem url';
- like $body, qr/This is some update text/, 'contains update text';
- unlike $body, qr/This is other update text/, 'does not contains other update text';
+ for my $email (@emails) {
+ my $body = $email->body;
+ my $to = $email->header('To');
+
+ like $body, qr/$msg/, 'email says problem is ' . $test->{state};
+ if ($to eq $user->email) {
+ like $body, qr{/M/}, 'contains problem login url';
+ } elsif ($to eq $user3->email) {
+ like $body, qr{/report/$report_id}, 'contains problem url';
+ }
+ like $body, qr/This is some update text/, 'contains update text';
+ unlike $body, qr/This is other update text/, 'does not contains other update text';
- my $comments = $body =~ s/(------)//gs;
- is $comments, 1, 'only 1 update';
+ my $comments = $body =~ s/(------)//gs;
+ is $comments, 1, 'only 1 update';
+ }
};
}
@@ -166,7 +187,6 @@ subtest "correct text for title after URL" => sub {
)->delete;
FixMyStreet::App->model('DB::AlertType')->email_alerts();
- $mech->email_count_is( 1 );
my $email = $mech->get_email;
(my $title = $report->title) =~ s/ /\\s+/;
my $body = $email->body;
@@ -300,7 +320,6 @@ foreach my $test (
FixMyStreet::App->model('DB::AlertType')->email_alerts();
- $mech->email_count_is( 1 );
my $email = $mech->get_email;
my $body = $email->body;
@@ -406,7 +425,6 @@ subtest "check alerts from cobrand send main site url for alerts for different c
FixMyStreet::App->model('DB::AlertType')->email_alerts();
- $mech->email_count_is( 1 );
my $email = $mech->get_email;
my $body = $email->body;
@@ -444,7 +462,6 @@ subtest "check local alerts from cobrand send main site url for alerts for diffe
FixMyStreet::App->model('DB::AlertType')->email_alerts();
- $mech->email_count_is( 1 );
my $email = $mech->get_email;
my $body = $email->body;
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index 8aabce4f7..9aa52c3cf 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -483,6 +483,10 @@ foreach my $test ( {
},
) {
subtest $test->{ desc } => sub {
+ if ( $test->{cobrand} && $test->{cobrand} =~ /lichfielddc/ && !FixMyStreet::Cobrand->exists('lichfielddc') ) {
+ plan skip_all => 'Skipping Lichfield tests without Lichfield cobrand';
+ }
+
$mech->clear_emails_ok;
FixMyStreet::App->model('DB::Problem')->search(
@@ -491,10 +495,6 @@ foreach my $test ( {
}
)->update( { whensent => \'ms_current_timestamp()' } );
- if ( $test->{cobrand} && $test->{cobrand} =~ /lichfielddc/ && !FixMyStreet::Cobrand->exists('lichfielddc') ) {
- plan skip_all => 'Skipping Lichfield tests without Lichfield cobrand';
- }
-
$problem->discard_changes;
$problem->update( {
council => $test->{ council },