diff options
Diffstat (limited to 't/cobrand')
-rw-r--r-- | t/cobrand/bromley.t | 2 | ||||
-rw-r--r-- | t/cobrand/fixamingata.t | 13 | ||||
-rw-r--r-- | t/cobrand/form_extras.t | 2 | ||||
-rw-r--r-- | t/cobrand/oxfordshire.t | 23 | ||||
-rw-r--r-- | t/cobrand/seesomething.t | 87 | ||||
-rw-r--r-- | t/cobrand/zurich.t | 12 | ||||
-rw-r--r-- | t/cobrand/zurich_attachments.txt | 2 |
7 files changed, 38 insertions, 103 deletions
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index 43d936684..a7cc563dc 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -55,7 +55,7 @@ subtest 'testing special Open311 behaviour', sub { $body->update( { send_method => 'Open311', endpoint => 'http://bromley.endpoint.example.com', jurisdiction => 'FMS', api_key => 'test' } ); my $test_data; FixMyStreet::override_config { - SEND_REPORTS_ON_STAGING => 1, + STAGING_FLAGS => { send_reports => 1 }, ALLOWED_COBRANDS => [ 'fixmystreet', 'bromley' ], }, sub { $test_data = FixMyStreet::DB->resultset('Problem')->send_reports(); diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t index 2ef3c09b4..d6a1c2b34 100644 --- a/t/cobrand/fixamingata.t +++ b/t/cobrand/fixamingata.t @@ -1,19 +1,22 @@ use strict; use warnings; use Test::More; -use LWP::Protocol::PSGI; +use Test::MockModule; BEGIN { use FixMyStreet; FixMyStreet->test_mode(1); } -use t::Mock::MapIt; use mySociety::Locale; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; +# Closest road reverse geocode mock +my $resolver = Test::MockModule->new('LWP::Simple'); +$resolver->mock('get', sub($) { "<result></result>" }); + # Front page test ok $mech->host("www.fixamingata.se"), "change host to FixaMinGata"; @@ -101,13 +104,9 @@ subtest "Test ajax decimal points" => sub { # requesting the page, so that the code performs a full switch to Swedish mySociety::Locale::push('en-gb'); - # A note to the future - the run_if_script line must be within a subtest - # otherwise it fails to work - LWP::Protocol::PSGI->register(t::Mock::MapIt->run_if_script, host => 'mapit.sweden'); - FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'fixamingata' ], - MAPIT_URL => 'http://mapit.sweden/' + MAPIT_URL => 'http://mapit.uk/' }, sub { $mech->get_ok('/ajax/lookup_location?term=12345'); # We want an actual decimal point in a JSON response... diff --git a/t/cobrand/form_extras.t b/t/cobrand/form_extras.t index c6f6976d5..22a86ef21 100644 --- a/t/cobrand/form_extras.t +++ b/t/cobrand/form_extras.t @@ -29,7 +29,7 @@ my $mech = FixMyStreet::TestMech->new; FixMyStreet::override_config { ALLOWED_COBRANDS => [ { tester => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/around'); $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } }, "submit location" ); diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index d9f880d07..b0fad3b56 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -45,6 +45,29 @@ subtest 'check /ajax defaults to open reports only' => sub { } }; +my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super User', is_superuser => 1); + +subtest 'Exor RDI download appears on Oxfordshire cobrand admin' => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { 'oxfordshire' => '.' } ], + }, sub { + $mech->log_in_ok( $superuser->email ); + $mech->get_ok('/admin'); + $mech->content_contains("Download Exor RDI"); + } +}; + +subtest 'Exor RDI download doesn’t appear outside of Oxfordshire cobrand admin' => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], + }, sub { + $mech->log_in_ok( $superuser->email ); + $mech->get_ok('/admin'); + $mech->content_lacks("Download Exor RDI"); + } +}; + # Clean up +$mech->delete_user( $superuser ); $mech->delete_problems_for_body( 2237 ); done_testing(); diff --git a/t/cobrand/seesomething.t b/t/cobrand/seesomething.t deleted file mode 100644 index 4da1c9c6e..000000000 --- a/t/cobrand/seesomething.t +++ /dev/null @@ -1,87 +0,0 @@ -use strict; -use warnings; -use DateTime; -use Test::More; - -use FixMyStreet; -use FixMyStreet::TestMech; - -my $EMAIL = 'seesomething@example.com'; - -my $mech = FixMyStreet::TestMech->new; -my $db = FixMyStreet::DB->storage->schema; -my $dt_parser = $db->storage->datetime_parser; - -$db->txn_begin; - -$db->resultset('Comment')->delete; -$db->resultset('Problem')->delete; - -my $user = $mech->create_user_ok( $EMAIL ); - -my $body = $mech->create_body_ok( 2520, 'Coventry City Council', id => 2520 ); -$mech->create_body_ok( 2522, 'Dudley Borough Council' ); -$mech->create_body_ok( 2514, 'Birmingham City Council' ); -$mech->create_body_ok( 2546, 'Walsall Borough Council' ); -$mech->create_body_ok( 2519, 'Wolverhampton City Council' ); -$mech->create_body_ok( 2538, 'Solihull Borough Council' ); -$mech->create_body_ok( 2535, 'Sandwell Borough Council' ); - -$user->update({ from_body => $body }); - -my $date = $dt_parser->format_datetime(DateTime->now); - -my $report = FixMyStreet::DB->resultset('Problem')->find_or_create( { - postcode => 'EH1 1BB', - bodies_str => '2520', - areas => ',2520,', - service => 'Android', - category => 'Bus', - subcategory => 'Loud Music', - title => 'Loud Music', - detail => 'Loud Music', - used_map => 1, - name => 'SeeSomething Test User', - anonymous => 0, - state => 'confirmed', - confirmed => $date, - lang => 'en-gb', - cobrand => 'default', - cobrand_data => '', - send_questionnaire => 1, - latitude => '52.4081', - longitude => '-1.5106', - user_id => $user->id, -} ); - -subtest 'admin/stats' => sub { - FixMyStreet::override_config { - ALLOWED_COBRANDS => [ 'seesomething' ], - }, sub { - my $user = $mech->log_in_ok( $EMAIL ); - - $mech->get( '/admin/stats' ); - if (ok $mech->success) { - - $date =~s/ / /; - $date =~s/\+0000//; - my $xml = <<EOXML; - <tr> - <td>Android</td> - <td>Bus</td> - <td class="nowrap">Loud Music</td> - <td class="nowrap">Coventry </td> - <td class="nowrap">$date</td> - </tr> -EOXML - $mech->content_contains($xml); - } - else { - diag $mech->content; - diag $mech->status; - }; - } -}; - -$db->txn_rollback; -done_testing; diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index ddaae1f90..0a84d2d03 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -28,12 +28,12 @@ ok $sample_file->exists, "sample file $sample_file exists"; my $sample_photo = $sample_file->slurp_raw; # This is a helper method that will send the reports but with the config -# correctly set - notably SEND_REPORTS_ON_STAGING needs to be true, and +# correctly set - notably STAGING_FLAGS send_reports needs to be true, and # zurich must be allowed cobrand if we want to be able to call cobrand # methods on it. sub send_reports_for_zurich { FixMyStreet::override_config { - SEND_REPORTS_ON_STAGING => 1, + STAGING_FLAGS => { send_reports => 1 }, ALLOWED_COBRANDS => ['zurich'] }, sub { # Actually send the report @@ -82,7 +82,7 @@ $subdivision->endpoint( 'subdivision@example.org' ); $subdivision->update; my $external_body = $mech->create_body_ok( 4, 'External Body' ); $external_body->send_method( 'Zurich' ); -$external_body->endpoint( 'external_body@example.org' ); +$external_body->endpoint( 'external_body@example.net' ); $external_body->update; sub get_export_rows_count { @@ -563,7 +563,7 @@ subtest "external report triggers email" => sub { send_reports_for_zurich(); $email = $mech->get_email; like $email->header('Subject'), qr/Weitergeleitete Meldung/, 'subject looks okay'; - like $email->header('To'), qr/external_body\@example.org/, 'to line looks correct'; + like $email->header('To'), qr/external_body\@example.net/, 'to line looks correct'; like $email->body, qr/External Body/, 'body has right name'; like $email->body, qr/$EXTERNAL_MESSAGE/, 'external_message was passed on'; unlike $email->body, qr/test\@example.com/, 'body does not contain email address'; @@ -599,7 +599,7 @@ subtest "external report triggers email" => sub { send_reports_for_zurich(); $email = $mech->get_email; like $email->header('Subject'), qr/Weitergeleitete Meldung/, 'subject looks okay'; - like $email->header('To'), qr/external_body\@example.org/, 'to line looks correct'; + like $email->header('To'), qr/external_body\@example.net/, 'to line looks correct'; like $email->body, qr/External Body/, 'body has right name'; like $email->body, qr/test\@example.com/, 'body does contain email address'; $mech->clear_emails_ok; @@ -630,7 +630,7 @@ subtest "external report triggers email" => sub { send_reports_for_zurich(); $email = $mech->get_email; like $email->header('Subject'), qr/Weitergeleitete Meldung/, 'subject looks okay'; - like $email->header('To'), qr/external_body\@example.org/, 'to line looks correct'; + like $email->header('To'), qr/external_body\@example.net/, 'to line looks correct'; like $email->body, qr/External Body/, 'body has right name'; like $email->body, qr/$EXTERNAL_MESSAGE/, 'external_message was passed on'; like $email->body, qr/test\@example.com/, 'body contains email address'; diff --git a/t/cobrand/zurich_attachments.txt b/t/cobrand/zurich_attachments.txt index bf8d6872b..25a1bacf0 100644 --- a/t/cobrand/zurich_attachments.txt +++ b/t/cobrand/zurich_attachments.txt @@ -1,7 +1,7 @@ MIME-Version: 1.0
Subject: =?iso-8859-1?Q?Z=FCri?= wie neu: Weitergeleitete Meldung #REPORT_ID
Content-Type: multipart/mixed; boundary="BOUNDARY"
-To: "External Body" <external_body@example.org>
+To: "External Body" <external_body@example.net>
Content-Transfer-Encoding: 7bit
From: "FixMyStreet" <division@example.org>
|