diff options
author | Matthew Somerville <matthew@mysociety.org> | 2014-02-26 19:23:49 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2014-02-26 19:23:49 +0000 |
commit | 3e5fa88255ccb7114cd920172cbe66c05b9fff3a (patch) | |
tree | 7d340ddccf38a0c53fcbfe551c6aa4f5045204c5 /t/app | |
parent | 8a431b9edb079d095cd3c7e3db391548b1e5d859 (diff) |
Make sure language is set early enough in email alert loop.
The call to set_lang_and_domain needs to happen before
the first string is translated (the report state).
Diffstat (limited to 't/app')
-rw-r--r-- | t/app/model/alert_type.t | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t index ac8013278..ae413978f 100644 --- a/t/app/model/alert_type.t +++ b/t/app/model/alert_type.t @@ -487,6 +487,31 @@ subtest "check local alerts from cobrand send main site url for alerts for diffe like $body, qr#$expected2#, 'cobrand area report point to cobrand url'; }; +# Test that email alerts are sent in the right language. +subtest "correct i18n-ed summary for state of closed" => sub { + $mech->clear_emails_ok; + + $report->update( { state => 'closed' } ); + $alert->update( { lang => 'nb', cobrand => 'fiksgatami' } ); + + FixMyStreet::App->model('DB::AlertSent')->search( { + alert_id => $alert->id, + parameter => $comment->id, + } )->delete; + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'fiksgatami' ], + }, sub { + FixMyStreet::App->model('DB::AlertType')->email_alerts(); + }; + + $mech->email_count_is( 1 ); + my $email = $mech->get_email; + my $body = $email->body; + my $msg = 'Denne rapporten er for tiden markert som lukket'; + like $body, qr/$msg/, 'email says problem is closed, in Norwegian'; +}; + END { $mech->delete_user($user) if $user; $mech->delete_user($user2) if $user2; |