diff options
author | Matthew Somerville <matthew@mysociety.org> | 2014-12-09 18:09:16 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2014-12-10 11:51:24 +0000 |
commit | bd09e5d135aff5abdf01f279b6258bc8cb250f8a (patch) | |
tree | d5a877714067962c40196fe6e7e9cfef42a08a81 /t/cobrand/fixamingata.t | |
parent | 819bac8ab6fa16fc260efb953db15c758dbc7109 (diff) |
Fix encoding of signature in emails.
This text was being imported encoded, which led to double-encoding when
used in templates. Fixes #960 and #961.
Diffstat (limited to 't/cobrand/fixamingata.t')
-rw-r--r-- | t/cobrand/fixamingata.t | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t new file mode 100644 index 000000000..daa7a2e8f --- /dev/null +++ b/t/cobrand/fixamingata.t @@ -0,0 +1,103 @@ +use strict; +use warnings; +use Test::More; + +BEGIN { + use FixMyStreet; + FixMyStreet->test_mode(1); +} + +use FixMyStreet::TestMech; +my $mech = FixMyStreet::TestMech->new; + +# Front page test + +ok $mech->host("www.fixamingata.se"), "change host to FixaMinGata"; +FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'fixamingata' ], +}, sub { + $mech->get_ok('/'); +}; +$mech->content_like( qr/FixaMinGata/ ); + +my $body = $mech->create_body_ok( 1, 'Body' ); +FixMyStreet::App->model('DB::Contact')->find_or_create({ + body => $body, + category => "Other", + email => "other\@example.org", + confirmed => 1, + deleted => 0, + editor => "Editor", + whenedited => \'now()', + note => 'Note', +}); + +my @reports = $mech->create_problems_for_body( 1, 1, 'Test', { + cobrand => 'fixamingata', + latitude => '55.605833', + longitude => '13.035833', +}); +my $report = $reports[0]; +$mech->get_ok( '/report/' . $report->id ); + +$mech->email_count_is(0); +FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'fixamingata' ], +}, sub { + FixMyStreet::App->model('DB::Problem')->send_reports(); +}; +my $email = $mech->get_email; +like $email->header('Content-Type'), qr/iso-8859-1/, 'encoding looks okay'; +like $email->header('Subject'), qr/Ny rapport: Test Test/, 'subject looks okay'; +like $email->header('To'), qr/other\@example.org/, 'to line looks correct'; +like $email->body, qr/V=E4nligen,/, 'signature looks correct'; +$mech->clear_emails_ok; + +my $user = + FixMyStreet::App->model('DB::User') + ->find_or_create( { email => 'test@example.com', name => 'Test User' } ); +ok $user, "created test user"; + +my $user2 = + FixMyStreet::App->model('DB::User') + ->find_or_create( { email => 'commenter@example.com', name => 'Commenter' } ); +ok $user2, "created comment user"; + +my $comment = FixMyStreet::App->model('DB::Comment')->find_or_create({ + problem_id => $report->id, + user_id => $user2->id, + name => 'Other User', + mark_fixed => 'false', + text => 'This is some update text', + state => 'confirmed', + anonymous => 'f', +}); +$comment->confirmed( \"ms_current_timestamp() - '3 days'::interval" ); +$comment->update; + +my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create({ + user => $user, + parameter => $report->id, + alert_type => 'new_updates', + whensubscribed => '2014-01-01 10:00:00', + confirmed => 1, + cobrand => 'fixamingata', +}); + +FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'fixamingata' ], +}, sub { + FixMyStreet::App->model('DB::AlertType')->email_alerts(); +}; + +$mech->email_count_is(1); +$email = $mech->get_email; +like $email->header('Content-Type'), qr/iso-8859-1/, 'encoding looks okay'; +like $email->body, qr/V=E4nligen,/, 'signature looks correct'; +$mech->clear_emails_ok; + +END { + $mech->delete_problems_for_body(1); + ok $mech->host("www.fixmystreet.com"), "change host back"; + done_testing(); +} |