aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
Diffstat (limited to 't/app')
-rw-r--r--t/app/01app.t4
-rw-r--r--t/app/controller/about.t18
-rw-r--r--t/app/controller/admin.t11
-rw-r--r--t/app/controller/auth_social.t117
-rw-r--r--t/app/controller/photo.t4
-rw-r--r--t/app/controller/questionnaire.t35
-rw-r--r--t/app/controller/report_interest_count.t24
-rw-r--r--t/app/controller/report_new.t4
-rw-r--r--t/app/controller/report_updates.t3
-rw-r--r--t/app/controller/reports.t16
-rw-r--r--t/app/helpers/send_email.t3
-rw-r--r--t/app/helpers/send_email_sample.txt4
-rw-r--r--t/app/helpers/send_email_sample_mime.txt106
-rw-r--r--t/app/model/alert_type.t2
-rw-r--r--t/app/model/photoset.t2
-rw-r--r--t/app/model/user.t2
-rw-r--r--t/app/sendreport/angus.t61
-rw-r--r--t/app/uri_for.t26
18 files changed, 285 insertions, 157 deletions
diff --git a/t/app/01app.t b/t/app/01app.t
index eb98b6319..df562b829 100644
--- a/t/app/01app.t
+++ b/t/app/01app.t
@@ -16,12 +16,16 @@ use Encode qw(encode);
ok( request('/')->is_success, 'Request should succeed' );
+SKIP: {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'tester' ],
}, sub {
+ skip 'Test will not pass on Mac OS', 1 if $^O eq 'darwin';
+
my $page = get('/');
my $num = encode('UTF-8', "12\N{NO-BREAK SPACE}345");
like $page, qr/$num/;
};
+}
done_testing();
diff --git a/t/app/controller/about.t b/t/app/controller/about.t
index 6a082a2ff..cec50abfa 100644
--- a/t/app/controller/about.t
+++ b/t/app/controller/about.t
@@ -1,3 +1,4 @@
+use utf8;
use strict;
use warnings;
@@ -21,19 +22,12 @@ ok !$mech->res->is_success(), "want a bad response";
is $mech->res->code, 404, "got 404";
FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'emptyhomes' ],
+ ALLOWED_COBRANDS => [ 'fiksgatami' ],
}, sub {
- # check that geting the page as EHA produces a different page
- ok $mech->host("reportemptyhomes.co.uk"), 'change host to reportemptyhomes';
- $mech->get_ok('/about');
- $mech->content_like(qr{About us ::});
- $mech->content_contains('html lang="en-gb"');
-
- # check that geting the page as EHA in welsh produces a different page
- ok $mech->host("cy.reportemptyhomes.co.uk"), 'host to cy.reportemptyhomes';
- $mech->get_ok('/about');
- $mech->content_like(qr{Amdanom ni ::});
- $mech->content_contains('html lang="cy"');
+ ok $mech->host("www.fiksgatami.no"), 'host to fiksgatami';
+ $mech->get_ok('/faq');
+ $mech->content_like(qr{Ofte spurte spørsmål ::});
+ $mech->content_contains('html class="no-js" lang="nb"');
};
done_testing();
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 92cbbc00f..1dcb768dc 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -104,9 +104,9 @@ subtest 'check summary counts' => sub {
$mech->content_contains( "$q_count questionnaires sent" );
FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'barnet' ],
+ ALLOWED_COBRANDS => [ 'oxfordshire' ],
}, sub {
- ok $mech->host('barnet.fixmystreet.com');
+ ok $mech->host('oxfordshire.fixmystreet.com');
$mech->get_ok('/admin');
$mech->title_like(qr/Summary/);
@@ -115,11 +115,11 @@ subtest 'check summary counts' => sub {
my ($num_alerts) = $mech->content =~ /(\d+) confirmed alerts/;
my ($num_qs) = $mech->content =~ /(\d+) questionnaires sent/;
- $report->bodies_str(2489);
- $report->cobrand('barnet');
+ $report->bodies_str(2237);
+ $report->cobrand('oxfordshire');
$report->update;
- $alert->cobrand('barnet');
+ $alert->cobrand('oxfordshire');
$alert->update;
$mech->get_ok('/admin');
@@ -171,6 +171,7 @@ subtest 'check contact creation' => sub {
email => 'test@example.com',
note => 'test note',
non_public => undef,
+ confirmed => 0,
} } );
$mech->content_contains( 'test category' );
diff --git a/t/app/controller/auth_social.t b/t/app/controller/auth_social.t
index 84fdd4dfe..6929c0ddc 100644
--- a/t/app/controller/auth_social.t
+++ b/t/app/controller/auth_social.t
@@ -6,6 +6,7 @@ use LWP::Simple;
use JSON::MaybeXS;
use t::Mock::Facebook;
+use t::Mock::Twitter;
use t::Mock::MapIt;
use FixMyStreet::TestMech;
@@ -21,6 +22,7 @@ LWP::Protocol::PSGI->register(t::Mock::MapIt->to_psgi_app, host => 'mapit.uk');
FixMyStreet::override_config {
FACEBOOK_APP_ID => 'facebook-app-id',
+ TWITTER_KEY => 'twitter-key',
ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
MAPIT_URL => 'http://mapit.uk/',
}, sub {
@@ -31,7 +33,10 @@ my $fb_uid = 123456789;
for my $fb_state ( 'refused', 'no email', 'existing UID', 'okay' ) {
for my $page ( 'my', 'report', 'update' ) {
subtest "test FB '$fb_state' login for page '$page'" => sub {
+ # Lots of user changes happening here, make sure we don't confuse
+ # Catalyst with a cookie session user that no longer exists
$mech->log_out_ok;
+ $mech->cookie_jar({});
if ($fb_state eq 'existing UID') {
my $user = $mech->create_user_ok($fb_email);
$user->update({ facebook_id => $fb_uid });
@@ -135,6 +140,118 @@ for my $fb_state ( 'refused', 'no email', 'existing UID', 'okay' ) {
}
}
+my $tw_email = 'twitter@example.org';
+my $tw_uid = 987654321;
+
+# Twitter has no way of getting the email, so no "okay" state here
+for my $tw_state ( 'refused', 'existing UID', 'no email' ) {
+ for my $page ( 'my', 'report', 'update' ) {
+ subtest "test Twitter '$tw_state' login for page '$page'" => sub {
+ # Lots of user changes happening here, make sure we don't confuse
+ # Catalyst with a cookie session user that no longer exists
+ $mech->log_out_ok;
+ $mech->cookie_jar({});
+ if ($tw_state eq 'existing UID') {
+ my $user = $mech->create_user_ok($tw_email);
+ $user->update({ twitter_id => $tw_uid });
+ } else {
+ $mech->delete_user($tw_email);
+ }
+
+ # Set up a mock to catch (most, see below) requests to Twitter
+ my $tw = t::Mock::Twitter->new;
+ LWP::Protocol::PSGI->register($tw->to_psgi_app, host => 'api.twitter.com');
+
+ # Due to https://metacpan.org/pod/Test::WWW::Mechanize::Catalyst#External-Redirects-and-allow_external
+ # the redirect to Twitter's OAuth page can mess up the session
+ # cookie. So let's pretend we always on api.twitter.com, which
+ # sorts that out.
+ $mech->host('api.twitter.com');
+
+ # Fetch the page with the form via which we wish to log in
+ my $fields;
+ if ($page eq 'my') {
+ $mech->get_ok('/my');
+ } elsif ($page eq 'report') {
+ $mech->get_ok('/');
+ $mech->submit_form_ok( { with_fields => { pc => 'SW1A1AA' } }, "submit location" );
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" );
+ $fields = {
+ title => 'Test title',
+ detail => 'Test detail',
+ };
+ } else {
+ $mech->get_ok('/report/' . $report->id);
+ $fields = {
+ update => 'Test update',
+ };
+ }
+ $mech->submit_form(with_fields => $fields, button => 'twitter_sign_in');
+
+ # As well as the cookie issue above, caused by this external
+ # redirect rewriting the host, the redirect gets handled directly
+ # by Catalyst, not our mocked handler, so will be a 404. Check
+ # the redirect happened instead.
+ is $mech->res->previous->code, 302, 'Twitter button redirected';
+ like $mech->res->previous->header('Location'), qr{api\.twitter\.com/oauth/authenticate\?oauth_token=request-token}, 'Twitter redirect to oauth URL';
+
+ # Okay, now call the callback Facebook would send us to
+ if ($tw_state eq 'refused') {
+ $mech->get_ok('/auth/Twitter?denied=token');
+ } else {
+ $mech->get_ok('/auth/Twitter?oauth_token=request-token&oauth_verifier=verifier');
+ }
+
+ # Check we're showing the right form, regardless of what came back
+ if ($page eq 'report') {
+ $mech->content_contains('/report/new');
+ } elsif ($page eq 'update') {
+ $mech->content_contains('/report/update');
+ }
+
+ if ($tw_state eq 'refused') {
+ $mech->content_contains('Sorry, we could not log you in. Please fill in the form below.');
+ $mech->not_logged_in_ok;
+ } elsif ($tw_state eq 'no email') {
+ $mech->content_contains('We need your email address, please give it below.');
+ # We don't have an email, so check that we can still submit it,
+ # and the ID carries through the confirmation
+ if ($page eq 'update') {
+ $fields->{rznvy} = $tw_email;
+ } else {
+ $fields->{email} = $tw_email;
+ }
+ $fields->{name} = 'Ffion Tester';
+ $mech->submit_form(with_fields => $fields);
+ $mech->content_contains('Nearly done! Now check your email');
+
+ my $email = $mech->get_email;
+ ok $email, "got an email";
+ $mech->clear_emails_ok;
+ my ( $url, $url_token ) = $email->body =~ m{(https?://\S+/[CMP]/)(\S+)};
+ ok $url, "extracted confirm url '$url'";
+
+ my $user = FixMyStreet::App->model( 'DB::User' )->find( { email => $tw_email } );
+ if ($page eq 'my') {
+ is $user, undef, 'No user yet exists';
+ } else {
+ is $user->twitter_id, undef, 'User has no twitter ID';
+ }
+ $mech->get_ok( $url . $url_token );
+ $user = FixMyStreet::App->model( 'DB::User' )->find( { email => $tw_email } );
+ is $user->twitter_id, $tw_uid, 'User now has correct twitter ID';
+
+ } elsif ($page ne 'my') {
+ # /my auth login goes directly there, no message like this
+ $mech->content_contains('You have successfully signed in; please check and confirm your details are accurate');
+ $mech->logged_in_ok;
+ } else {
+ is $mech->uri->path, '/my', 'Successfully on /my page';
+ }
+ }
+ }
+}
+
};
END {
diff --git a/t/app/controller/photo.t b/t/app/controller/photo.t
index 39380e769..425e3c4df 100644
--- a/t/app/controller/photo.t
+++ b/t/app/controller/photo.t
@@ -65,10 +65,10 @@ subtest "Check multiple upload worked" => sub {
ok $mech->success, 'Made request with multiple photo upload';
$mech->base_is('http://localhost/report/new');
$mech->content_like(
- qr[(<img align="right" src="/photo/1cdd4329ceee2234bd4e89cb33b42061a0724687.temp.jpeg" alt="">\s*){3}],
+ qr[(<img align="right" src="/photo/temp.1cdd4329ceee2234bd4e89cb33b42061a0724687.jpeg" alt="">\s*){3}],
'Three uploaded pictures are all shown, safe');
$mech->content_contains(
- 'name="upload_fileid" value="1cdd4329ceee2234bd4e89cb33b42061a0724687,1cdd4329ceee2234bd4e89cb33b42061a0724687,1cdd4329ceee2234bd4e89cb33b42061a0724687"',
+ 'name="upload_fileid" value="1cdd4329ceee2234bd4e89cb33b42061a0724687.jpeg,1cdd4329ceee2234bd4e89cb33b42061a0724687.jpeg,1cdd4329ceee2234bd4e89cb33b42061a0724687.jpeg"',
'Returned upload_fileid contains expected hash, 3 times');
my $image_file = path($UPLOAD_DIR, '1cdd4329ceee2234bd4e89cb33b42061a0724687.jpeg');
ok $image_file->exists, 'File uploaded to temp';
diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t
index 7718d5034..7bc6545db 100644
--- a/t/app/controller/questionnaire.t
+++ b/t/app/controller/questionnaire.t
@@ -63,8 +63,8 @@ my $email = $mech->get_email;
ok $email, "got an email";
like $email->body, qr/fill in our short questionnaire/i, "got questionnaire email";
-like $email->body, qr/Testing =96 Detail/, 'email contains encoded character';
-is $email->header('Content-Type'), 'text/plain; charset="windows-1252"', 'in the right character set';
+like $email->body_str, qr/Testing \x{2013} Detail/, 'email contains encoded character';
+is $email->header('Content-Type'), 'text/plain; charset="utf-8"', 'in the right character set';
my ($token) = $email->body =~ m{http://.*?/Q/(\S+)};
ok $token, "extracted questionnaire token '$token'";
@@ -394,31 +394,23 @@ for my $test (
}
FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'emptyhomes', 'fixmystreet' ],
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
}, sub {
- # EHA extra checking
- ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes';
-
- # Reset, and all the questionaire sending function - FIXME should it detect site itself somehow?
+ $report->discard_changes;
$report->send_questionnaire( 1 );
$report->update;
$questionnaire->delete;
- FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires( {
- site => 'emptyhomes'
- } );
+ FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires();
$email = $mech->get_email;
ok $email, "got an email";
$mech->clear_emails_ok;
(my $body = $email->body) =~ s/\s+/ /g;
- like $body, qr/fill in this short questionnaire/i, "got questionnaire email";
+ like $body, qr/fill in our short questionnaire/i, "got questionnaire email";
($token) = $email->body =~ m{http://.*?/Q/(\S+)};
ok $token, "extracted questionnaire token '$token'";
- $mech->get_ok("/Q/" . $token);
- $mech->content_lacks( 'Would you like to receive another questionnaire' );
-
# Test already answered the ever reported question, so not shown again
$dt = $dt->add( weeks => 4 );
my $questionnaire2 = FixMyStreet::App->model('DB::Questionnaire')->find_or_create(
@@ -429,17 +421,11 @@ FixMyStreet::override_config {
}
);
ok $questionnaire2, 'added another questionnaire';
- ok $mech->host("www.fixmystreet.com"), 'change host to fixmystreet';
$mech->get_ok("/Q/" . $token);
$mech->title_like( qr/Questionnaire/ );
$mech->content_contains( 'Has this problem been fixed?' );
$mech->content_lacks( 'ever reported' );
- # EHA extra checking
- ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes';
- $mech->get_ok("/Q/" . $token);
- $mech->content_lacks( 'Would you like to receive another questionnaire' );
-
$token = FixMyStreet::App->model("DB::Token")->find( { scope => 'questionnaire', token => $token } );
ok $token, 'found token for questionnaire';
$questionnaire = FixMyStreet::App->model('DB::Questionnaire')->find( { id => $token->data } );
@@ -452,18 +438,19 @@ FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fiksgatami' ],
}, sub {
# I18N Unicode extra testing using FiksGataMi
+ $report->discard_changes;
$report->send_questionnaire( 1 );
$report->cobrand( 'fiksgatami' );
$report->update;
$questionnaire->delete;
- FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires( { site => 'fixmystreet' } ); # It's either fixmystreet or emptyhomes
+ FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires();
$email = $mech->get_email;
ok $email, "got an email";
$mech->clear_emails_ok;
- like $email->body, qr/Testing =96 Detail/, 'email contains encoded character from user';
- like $email->body, qr/sak p=E5 FiksGataMi/, 'email contains encoded character from template';
- is $email->header('Content-Type'), 'text/plain; charset="windows-1252"', 'email is in right encoding';
+ like $email->body_str, qr/Testing \x{2013} Detail/, 'email contains encoded character from user';
+ like $email->body_str, qr/sak p\xe5 FiksGataMi/, 'email contains encoded character from template';
+ is $email->header('Content-Type'), 'text/plain; charset="utf-8"', 'email is in right encoding';
};
$mech->delete_user('test@example.com');
diff --git a/t/app/controller/report_interest_count.t b/t/app/controller/report_interest_count.t
index 506b50edd..4e86789ba 100644
--- a/t/app/controller/report_interest_count.t
+++ b/t/app/controller/report_interest_count.t
@@ -1,5 +1,16 @@
use strict;
use warnings;
+
+package FixMyStreet::Cobrand::Tester;
+
+use parent 'FixMyStreet::Cobrand::Default';
+
+sub can_support_problems {
+ return 1;
+}
+
+package main;
+
use Test::More;
use FixMyStreet::TestMech;
@@ -52,7 +63,7 @@ my $report_id = $report->id;
ok $report, "created test report - $report_id";
FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'fixmybarangay' ],
+ ALLOWED_COBRANDS => [ 'tester' ],
}, sub {
my $body = $mech->create_body_ok(2504, 'Westminster City Council');
@@ -76,7 +87,6 @@ FixMyStreet::override_config {
},
) {
subtest $test->{desc} => sub {
- ok $mech->host('fixmybarangay.com'), 'changed to fixmybarangay';
$mech->log_in_ok( $user->email );
$user->from_body( $test->{from_body} );
$user->update;
@@ -92,7 +102,7 @@ FixMyStreet::override_config {
$mech->content_contains('Add support');
$mech->submit_form_ok( { form_number => 1 } );
- is $mech->uri, "http://fixmybarangay.com/report/$report_id", 'add support redirects to report page';
+ is $mech->uri->path, "/report/$report_id", 'add support redirects to report page';
$mech->content_contains($test->{updated_support});
} else {
@@ -102,26 +112,22 @@ FixMyStreet::override_config {
}
subtest 'check non body user cannot increment support count' => sub {
- ok $mech->host('fixmybarangay.com'), 'changed to fixmybarangay';
-
ok $report->update({ interest_count => 1 }), 'updated interest count';
is $report->interest_count, 1, 'correct interest count';
$mech->get_ok("/report/$report_id");
$mech->content_contains( '1 supporter' );
- # This doesn't send cookie, so is logged out
+ $mech->log_out_ok( $user->email );
$mech->post_ok("/report/support", { id => $report_id } );
- is $mech->uri, "http://fixmybarangay.com/report/$report_id", 'add support redirects to report page';
+ is $mech->uri->path, "/report/$report_id", 'add support redirects to report page';
$mech->content_contains( '1 supporter' );
};
};
subtest 'check support details not shown if not enabled in cobrand' => sub {
- ok $mech->host('www.fixmystreet.com'), 'changed to fixmystreet';
-
$report->interest_count(1);
ok $report->update, 'updated interest count';
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index cf72221b4..eb29d37da 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -420,7 +420,7 @@ foreach my $test (
changes => {
photo1 => '',
},
- errors => [ "Please upload a JPEG image only" ],
+ errors => [ "Please upload an image only" ],
},
{
msg => 'bad photo upload gives error',
@@ -443,7 +443,7 @@ foreach my $test (
changes => {
photo1 => '',
},
- errors => [ "That image doesn't appear to have uploaded correctly (Please upload a JPEG image only ), please try again." ],
+ errors => [ "That image doesn't appear to have uploaded correctly (Please upload an image only ), please try again." ],
},
{
msg => 'photo with octet-stream gets through okay',
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index f9f5189e5..7b4bf7854 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -760,7 +760,8 @@ subtest 'check meta correct for comments marked confirmed but not marked open' =
user => $user,
problem_id => $report->id,
text => 'update text',
- confirmed => DateTime->now( time_zone => 'local' ),
+ # Subtract a day to deal with any code/db timezone difference
+ confirmed => DateTime->now( time_zone => 'local' ) - DateTime::Duration->new( days => 1 ),
problem_state => 'confirmed',
anonymous => 0,
mark_open => 0,
diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t
index 02625fcc7..8869adaa7 100644
--- a/t/app/controller/reports.t
+++ b/t/app/controller/reports.t
@@ -12,6 +12,7 @@ $mech->create_body_ok(2514, 'Birmingham City Council');
my $body_edin_id = $mech->create_body_ok(2651, 'City of Edinburgh Council')->id;
my $body_west_id = $mech->create_body_ok(2504, 'Westminster City Council')->id;
my $body_fife_id = $mech->create_body_ok(2649, 'Fife Council')->id;
+my $body_slash_id = $mech->create_body_ok(10000, 'Electricity/Gas Council')->id;
$mech->delete_problems_for_body( $body_west_id );
$mech->delete_problems_for_body( $body_edin_id );
@@ -122,6 +123,10 @@ is scalar @$problems, 5, 'correct number of problems displayed';
FixMyStreet::override_config {
MAPIT_URL => 'http://mapit.mysociety.org/',
}, sub {
+ $mech->get_ok('/reports');
+ $mech->follow_link_ok({ url_regex => qr{/reports/Electricity_Gas\+Council} });
+ is $mech->uri->path, '/reports/Electricity_Gas+Council', 'Path is correct';
+
$mech->get_ok('/reports/City+of+Edinburgh?t=new');
};
$problems = $mech->extract_problem_list;
@@ -191,17 +196,6 @@ $mech->get_ok('/reports');
$stats = $mech->extract_report_stats;
is $stats->{'Westminster City Council'}->[1], 5, 'non public reports included in stats';
-subtest "test emptyhomes all reports page" => sub {
- FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'emptyhomes' ],
- }, sub {
- ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes';
- $mech->get_ok('/reports');
- # EHA lacks one column the others have
- $mech->content_lacks('state unknown');
- };
-};
-
subtest "test fiksgatami all reports page" => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fiksgatami' ],
diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t
index f60f7fa5a..e2c8688a8 100644
--- a/t/app/helpers/send_email.t
+++ b/t/app/helpers/send_email.t
@@ -41,8 +41,7 @@ my $email = Email::MIME->new($email_as_string);
my $expected_email_content = path(__FILE__)->parent->child('send_email_sample.txt')->slurp;
my $name = FixMyStreet->config('CONTACT_NAME');
-$name = "\"$name\"" if $name =~ / /;
-my $sender = $name . ' <' . FixMyStreet->config('DO_NOT_REPLY_EMAIL') . '>';
+my $sender = '"' . $name . '" <' . FixMyStreet->config('DO_NOT_REPLY_EMAIL') . '>';
$expected_email_content =~ s{CONTACT_EMAIL}{$sender};
my $expected_email = Email::MIME->new($expected_email_content);
diff --git a/t/app/helpers/send_email_sample.txt b/t/app/helpers/send_email_sample.txt
index 1ccce6a23..0f7406172 100644
--- a/t/app/helpers/send_email_sample.txt
+++ b/t/app/helpers/send_email_sample.txt
@@ -1,5 +1,5 @@
MIME-Version: 1.0
-Subject: test email =?utf-8?Q?=E2=98=BA?=
+Subject: =?UTF-8?B?dGVzdCBlbWFpbCDimLo=?=
Content-Type: text/plain; charset="utf-8"
To: test@recipient.com
Content-Transfer-Encoding: quoted-printable
@@ -24,5 +24,3 @@ culpa qui officia deserunt mollit anim id est laborum.
Yours,=20=20
FixMyStreet.=20=
-
-
diff --git a/t/app/helpers/send_email_sample_mime.txt b/t/app/helpers/send_email_sample_mime.txt
index c4ca97bcc..0649d1ceb 100644
--- a/t/app/helpers/send_email_sample_mime.txt
+++ b/t/app/helpers/send_email_sample_mime.txt
@@ -1,57 +1,49 @@
-MIME-Version: 1.0
-Subject: test email =?utf-8?Q?=E2=98=BA?=
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-To: test@recipient.com
-Content-Transfer-Encoding: 7bit
-From: CONTACT_EMAIL
-
-
---BOUNDARY
-MIME-Version: 1.0
-Subject: test email =?utf-8?Q?=E2=98=BA?=
-Content-Type: text/plain; charset="utf-8"
-To: test@recipient.com
-Content-Transfer-Encoding: quoted-printable
-From: CONTACT_EMAIL
-
-Hello,
-
-This is a test email where foo: bar.
-
-utf8: =E6=88=91=E4=BB=AC=E5=BA=94=E8=AF=A5=E8=83=BD=E5=A4=9F=E6=97=A0=E7=BC=
-=9D=E5=A4=84=E7=90=86UTF8=E7=BC=96=E7=A0=81
-
- indented_text
-
-long line: Lorem ipsum dolor sit amet, consectetur adipisicing elit,
-sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
-reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
-pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
-culpa qui officia deserunt mollit anim id est laborum.
-
-Yours,=20=20
-FixMyStreet.=20=
-
-
-
---BOUNDARY
-MIME-Version: 1.0
-Content-Type: image/gif; name="foo.gif"
-Content-Disposition: inline; filename="foo.gif"
-Content-Transfer-Encoding: quoted-printable
-
-GIF89a=01=00=01=00=80=00=00=00=00=00=CC=CC=CC,=00=00=00=00=01=00=01=00=00=
-=02=01L=00;=
-
---BOUNDARY
-MIME-Version: 1.0
-Content-Type: image/gif; name="bar.gif"
-Content-Disposition: inline; filename="bar.gif"
-Content-Transfer-Encoding: quoted-printable
-
-GIF89a=01=00=01=00=80=00=00=00=00=00=CC=CC=CC,=00=00=00=00=01=00=01=00=00=
-=02=01L=00;=
-
---BOUNDARY--
+MIME-Version: 1.0
+Subject: =?UTF-8?B?dGVzdCBlbWFpbCDimLo=?=
+Content-Type: multipart/mixed; boundary="BOUNDARY"
+To: test@recipient.com
+Content-Transfer-Encoding: 7bit
+From: CONTACT_EMAIL
+
+
+--BOUNDARY
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: quoted-printable
+
+Hello,
+
+This is a test email where foo: bar.
+
+utf8: =E6=88=91=E4=BB=AC=E5=BA=94=E8=AF=A5=E8=83=BD=E5=A4=9F=E6=97=A0=E7=BC=
+=9D=E5=A4=84=E7=90=86UTF8=E7=BC=96=E7=A0=81
+
+ indented_text
+
+long line: Lorem ipsum dolor sit amet, consectetur adipisicing elit,
+sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
+nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
+reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
+pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
+culpa qui officia deserunt mollit anim id est laborum.
+
+Yours,=20=20
+FixMyStreet.=20=
+
+--BOUNDARY
+Content-Type: image/gif; name="foo.gif"
+Content-Disposition: inline; filename="foo.gif"
+Content-Transfer-Encoding: quoted-printable
+
+GIF89a=01=00=01=00=80=00=00=00=00=00=CC=CC=CC,=00=00=00=00=01=00=01=00=00=
+=02=01L=00;=
+
+--BOUNDARY
+Content-Type: image/gif; name="bar.gif"
+Content-Disposition: inline; filename="bar.gif"
+Content-Transfer-Encoding: quoted-printable
+
+GIF89a=01=00=01=00=80=00=00=00=00=00=CC=CC=CC,=00=00=00=00=01=00=01=00=00=
+=02=01L=00;=
+
+--BOUNDARY--
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t
index 0130f404e..e94ee8ce1 100644
--- a/t/app/model/alert_type.t
+++ b/t/app/model/alert_type.t
@@ -287,7 +287,7 @@ foreach my $test (
desc => 'address only',
addressLine => '18 North Bridge',
locality => undef,
- nearest => qr/: 18 North Bridge\n/,
+ nearest => qr/: 18 North Bridge\r?\n/,
},
{
desc => 'no fields',
diff --git a/t/app/model/photoset.t b/t/app/model/photoset.t
index cfb5236a8..577e39eb1 100644
--- a/t/app/model/photoset.t
+++ b/t/app/model/photoset.t
@@ -58,7 +58,7 @@ subtest 'Photoset with photo inline in DB' => sub {
my $report = make_report( $image_path->slurp );
my $photoset = $report->get_photoset();
is $photoset->num_images, 1, 'Found just 1 image';
- is $photoset->data, '1cdd4329ceee2234bd4e89cb33b42061a0724687';
+ is $photoset->data, '1cdd4329ceee2234bd4e89cb33b42061a0724687.jpeg';
};
$image_path->copy( path( $UPLOAD_DIR, '0123456789012345678901234567890123456789.jpeg' ) );
diff --git a/t/app/model/user.t b/t/app/model/user.t
index 24e5d2d98..bf73a9d09 100644
--- a/t/app/model/user.t
+++ b/t/app/model/user.t
@@ -46,7 +46,7 @@ END {
sub create_update {
my ($problem, %params) = @_;
- my $dt = DateTime->now()->add(hours => 1);
+ my $dt = DateTime->now()->add(days => 1);
return FixMyStreet::App->model('DB::Comment')->find_or_create({
problem_id => $problem->id,
user_id => $problem->user_id,
diff --git a/t/app/sendreport/angus.t b/t/app/sendreport/angus.t
new file mode 100644
index 000000000..a19ee483a
--- /dev/null
+++ b/t/app/sendreport/angus.t
@@ -0,0 +1,61 @@
+use strict;
+use warnings;
+
+use FixMyStreet::DB;
+
+use Test::More;
+
+use_ok("FixMyStreet::SendReport::Angus");
+
+my $u = FixMyStreet::DB->resultset('User')->new( { email => 'test@example.org', name => 'A User' } );
+
+my $p = FixMyStreet::DB->resultset('Problem')->new( {
+ latitude => 1,
+ longitude => 1,
+ title => 'title',
+ detail => 'detail',
+ user => $u,
+ id => 1,
+ name => 'A User',
+ cobrand => 'fixmystreet',
+} );
+
+my $angus = FixMyStreet::SendReport::Angus->new();
+
+subtest 'parses authentication token correctly' => sub {
+ my $authxml = <<EOT;
+ <AuthenticateResponse>
+
+ <AuthenticateResult>
+ TVRreUxqRTJPQzR5TlRVdU1qSjhNakF4Tmpvd01Ub3lNam94TlRvME16b3pPUT09VGhvdVNoYWx0Tm90UGFzcw==
+ </AuthenticateResult>
+ <success>
+ True
+ </success>
+ <message></message>
+
+ </AuthenticateResponse>
+EOT
+;
+ is $angus->get_auth_token($authxml), 'TVRreUxqRTJPQzR5TlRVdU1qSjhNakF4Tmpvd01Ub3lNam94TlRvME16b3pPUT09VGhvdVNoYWx0Tm90UGFzcw==', 'token correct';
+};
+
+subtest 'parses report external id correctly' => sub {
+ my $respxml = <<EOT;
+<CreateRequestResponse>
+
+ <CreateRequestResult>
+ <RequestId>7245</RequestId>
+ </CreateRequestResult>
+
+ <success>True</success>
+ <message></message>
+
+</CreateRequestResponse>
+EOT
+;
+ is $angus->get_external_id($respxml), '7245', 'external id correct';
+};
+
+
+done_testing();
diff --git a/t/app/uri_for.t b/t/app/uri_for.t
index 810aade62..9cbcd3767 100644
--- a/t/app/uri_for.t
+++ b/t/app/uri_for.t
@@ -17,7 +17,6 @@ use_ok('FixMyStreet::App');
my $fms_c = ctx_request('http://www.fixmystreet.com/');
my $fgm_c = ctx_request('http://www.fiksgatami.no/');
-my $reh_en_c = ctx_request('http://reportemptyhomes.com/');
is(
$fms_c->uri_for('/bar/baz') . "",
@@ -44,29 +43,4 @@ is(
'FiksGataMi url with lat not zoom'
);
-FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'emptyhomes' ],
-}, sub {
- like(
- $reh_en_c->uri_for_email( '/foo' ),
- qr{^http://en.},
- 'adds en to retain language'
- );
-};
-
-# instantiate this here otherwise sets locale to cy and breaks test
-# above
-my $reh_cy_c;
-FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'emptyhomes' ],
-}, sub {
- $reh_cy_c = ctx_request('http://cy.reportemptyhomes.com/');
-
- like(
- $reh_cy_c->uri_for_email( '/foo' ),
- qr{^http://cy.},
- 'retains language'
- );
-};
-
done_testing();