diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-03-21 17:23:07 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-03-23 18:48:55 +0000 |
commit | 8bdf783d5d18dde25b4d2f8309a42c6096cf09d3 (patch) | |
tree | d725016fcc8429c55b3c0266bb23ac8d56b4a243 | |
parent | 02fcb1606bc2b739fdc798e5ca06f2ed1b6bf6ea (diff) |
Always include MapIt mock handler in all tests.
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 1 | ||||
-rw-r--r-- | t/Mock/MapIt.pm | 3 | ||||
-rw-r--r-- | t/app/controller/admin.t | 3 | ||||
-rw-r--r-- | t/app/controller/admin_permissions.t | 4 | ||||
-rw-r--r-- | t/app/controller/around.t | 4 | ||||
-rw-r--r-- | t/app/controller/auth_social.t | 3 | ||||
-rw-r--r-- | t/app/controller/report_as_other.t | 3 | ||||
-rw-r--r-- | t/app/controller/report_import.t | 4 | ||||
-rw-r--r-- | t/cobrand/fixamingata.t | 8 |
9 files changed, 5 insertions, 28 deletions
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index 122a5d0c9..902ae7a5a 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -10,6 +10,7 @@ BEGIN { } use Test::WWW::Mechanize::Catalyst 'FixMyStreet::App'; +use t::Mock::MapIt; use Test::More; use Web::Scraper; use Carp; diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index 9aa8b7e40..c3bafc6ca 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -2,6 +2,7 @@ package t::Mock::MapIt; use JSON::MaybeXS; use Web::Simple; +use LWP::Protocol::PSGI; use mySociety::Locale; @@ -71,4 +72,6 @@ sub postcode { }; } +LWP::Protocol::PSGI->register(t::Mock::MapIt->to_psgi_app, host => 'mapit.uk'); + __PACKAGE__->run_if_script; diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index ab6cac842..be3d6d08e 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -1,9 +1,7 @@ use strict; use warnings; use Test::More; -use LWP::Protocol::PSGI; -use t::Mock::MapIt; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -1204,7 +1202,6 @@ my %default_perms = ( FixMyStreet::override_config { MAPIT_URL => 'http://mapit.uk/', }, sub { - LWP::Protocol::PSGI->register(t::Mock::MapIt->run_if_script, host => 'mapit.uk'); for my $test ( { desc => 'edit user name', diff --git a/t/app/controller/admin_permissions.t b/t/app/controller/admin_permissions.t index 4b05660cc..dd256173d 100644 --- a/t/app/controller/admin_permissions.t +++ b/t/app/controller/admin_permissions.t @@ -1,9 +1,7 @@ use strict; use warnings; use Test::More; -use LWP::Protocol::PSGI; -use t::Mock::MapIt; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -84,8 +82,6 @@ FixMyStreet::override_config { MAPIT_URL => 'http://mapit.uk/', ALLOWED_COBRANDS => [ 'oxfordshire' ], }, sub { - LWP::Protocol::PSGI->register(t::Mock::MapIt->run_if_script, host => 'mapit.uk'); - my $user2_id = $user2->id; $report->update({ bodies_str => $oxfordshire->id }); diff --git a/t/app/controller/around.t b/t/app/controller/around.t index 9e2e7c524..eece843a8 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -1,9 +1,7 @@ use strict; use warnings; use Test::More; -use LWP::Protocol::PSGI; -use t::Mock::MapIt; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -84,8 +82,6 @@ foreach my $test ( ) { subtest "check lat/lng for '$test->{pc}'" => sub { - LWP::Protocol::PSGI->register(t::Mock::MapIt->run_if_script, host => 'mapit.uk'); - $mech->get_ok('/'); FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], diff --git a/t/app/controller/auth_social.t b/t/app/controller/auth_social.t index f3eae32a7..52cc2766c 100644 --- a/t/app/controller/auth_social.t +++ b/t/app/controller/auth_social.t @@ -7,7 +7,6 @@ use JSON::MaybeXS; use t::Mock::Facebook; use t::Mock::Twitter; -use t::Mock::MapIt; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -18,8 +17,6 @@ END { FixMyStreet::App->log->enable('info'); } my ($report) = $mech->create_problems_for_body(1, '2345', 'Test'); -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', diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t index b4405be57..a0597c7c6 100644 --- a/t/app/controller/report_as_other.t +++ b/t/app/controller/report_as_other.t @@ -1,9 +1,7 @@ use strict; use warnings; use Test::More; -use LWP::Protocol::PSGI; -use t::Mock::MapIt; use FixMyStreet::TestMech; use FixMyStreet::App; @@ -134,7 +132,6 @@ END { sub start_report { my $permission = shift; - LWP::Protocol::PSGI->register(t::Mock::MapIt->run_if_script, host => 'mapit.uk'); $_->delete for $user->user_body_permissions; $user->user_body_permissions->create({ body => $body, permission_type => $permission }) if $permission; diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t index 6c0da221c..9201f600c 100644 --- a/t/app/controller/report_import.t +++ b/t/app/controller/report_import.t @@ -1,9 +1,7 @@ use strict; use warnings; use Test::More; -use LWP::Protocol::PSGI; -use t::Mock::MapIt; use FixMyStreet::TestMech; use FixMyStreet::App; use Web::Scraper; @@ -92,8 +90,6 @@ subtest "Test creating bad partial entries" => sub { }; subtest "Submit a correct entry" => sub { - LWP::Protocol::PSGI->register(t::Mock::MapIt->run_if_script, host => 'mapit.uk'); - $mech->get_ok('/import'); $mech->submit_form_ok( # diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t index 2ef3c09b4..dacf4325a 100644 --- a/t/cobrand/fixamingata.t +++ b/t/cobrand/fixamingata.t @@ -1,14 +1,12 @@ use strict; use warnings; use Test::More; -use LWP::Protocol::PSGI; BEGIN { use FixMyStreet; FixMyStreet->test_mode(1); } -use t::Mock::MapIt; use mySociety::Locale; use FixMyStreet::TestMech; @@ -101,13 +99,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... |