diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-03-28 10:12:56 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-03-28 10:12:56 +0100 |
commit | b76cfb3889140f1c771c1f98254f724aad3d4297 (patch) | |
tree | bb7beada7a603119ea2897f54a6af96814d850e1 | |
parent | 3f21a9742d89c3e4fda47a0be6ec2a17f802c99a (diff) | |
parent | a8ceae6c99b00aefcba301b2f41033d84701f56a (diff) |
Merge branch 'offline-tests'
26 files changed, 191 insertions, 165 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Auth.pm b/perllib/FixMyStreet/App/Controller/Auth.pm index 70821f79d..4efa7abb8 100644 --- a/perllib/FixMyStreet/App/Controller/Auth.pm +++ b/perllib/FixMyStreet/App/Controller/Auth.pm @@ -104,7 +104,7 @@ sub sign_in : Private { Email the user the details they need to sign in. Don't check for an account - if there isn't one we can create it when they come back with a token (which -contains the email addresss). +contains the email address). =cut diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 12280db47..fe7576893 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -275,7 +275,7 @@ sub delete :Local :Args(1) { $p->user->update_reputation(-1); $c->model('DB::AdminLog')->create( { - user => $c->user, + user => $c->user->obj, admin_user => $c->user->from_body->name, object_type => 'problem', action => 'state_change', diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index 70d5c05ed..881572a38 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..43d44d519 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; @@ -12,42 +13,83 @@ has json => ( }, ); +sub output { + my ($self, $response) = @_; + # We must make sure we output correctly for testing purposes, we might + # be within a different locale here... + my $json = mySociety::Locale::in_gb_locale { + $self->json->encode($response) }; + return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; +} + +my @PLACES = ( + [ 'EH1 1BB', 55.952055, -3.189579, 2651, 'Edinburgh City Council', 'UTA', 20728, 'City Centre', 'UTE' ], + [ 'SW1A 1AA', 51.501009, -0.141588, 2504, 'Westminster City Council', 'LBO' ], + [ 'GL50 2PR', 51.896268, -2.093063, 2226, 'Gloucestershire County Council', 'CTY', 2326, 'Cheltenham Borough Council', 'DIS', 4544, 'Lansdown', 'DIW', 143641, 'Lansdown and Park', 'CED' ], + [ '?', 51.754926, -1.256179, 2237, 'Oxfordshire County Council', 'CTY', 2421, 'Oxford City Council', 'DIS' ], + [ 'BR1 3UH', 51.4021, 0.01578, 2482, 'Bromley Council', 'LBO' ], + [ '?', 50.78301, -0.646929 ], + [ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ], + [ 'WS1 4NH', 52.563074, -1.991032, 2535, 'Sandwell Borough Council', 'MTD' ], +); + sub dispatch_request { my $self = shift; sub (GET + /postcode/*) { my ($self, $postcode) = @_; - my $response = $self->postcode($postcode); - # We must make sure we output correctly for testing purposes, we might - # be within a different locale here... - my $json = mySociety::Locale::in_gb_locale { - $self->json->encode($response) }; - return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; + foreach (@PLACES) { + if ($postcode eq $_->[0] || $postcode eq $_->[0] =~ s/ //gr) { + return $self->output({wgs84_lat => $_->[1], wgs84_lon => $_->[2], postcode => $postcode, coordsyst => 'G'}); + } + } + my $response = { + wgs84_lat => 51.5, wgs84_lon => -2.1, postcode => $postcode, coordsyst => 'G', + }; + return $self->output($response); }, - sub (GET + /point/**) { + sub (GET + /point/**.*) { my ($self, $point) = @_; + foreach (@PLACES) { + if ($point eq "4326/$_->[2],$_->[1]") { + my %out; + for (my $i=3; $i<@$_; $i+=3) { + $out{"$_->[$i]"} = { id => $_->[$i], name => $_->[$i+1], type => $_->[$i+2] }; + } + return $self->output(\%out); + } + } my $response = { "63999" => {"parent_area" => 2245, "generation_high" => 25, "all_names" => {}, "id" => 63999, "codes" => {"ons" => "00HYNS", "gss" => "E05008366", "unit_id" => "44025"}, "name" => "Kington", "country" => "E", "type_name" => "Unitary Authority electoral division (UTE)", "generation_low" => 12, "country_name" => "England", "type" => "UTE"}, - "65822" => {"parent_area" => undef, "generation_high" => 25, "all_names" => {}, "id" => 65822, "codes" => {"gss" => "E14000860", "unit_id" => "24903"}, "name" => "North Wiltshire", "country" => "E", "type_name" => "UK Parliament constituency", "generation_low" => 13, "country_name" => "England", "type" => "WMC"}, - "11814" => {"parent_area" => undef, "generation_high" => 25, "all_names" => {}, "id" => 11814, "codes" => {"ons" => "09", "gss" => "E15000009", "unit_id" => "41427"}, "name" => "South West", "country" => "E", "type_name" => "European region", "generation_low" => 1, "country_name" => "England", "type" => "EUR"}, "2245" => {"parent_area" => undef, "generation_high" => 25, "all_names" => {}, "id" => 2245, "codes" => {"ons" => "00HY", "gss" => "E06000054", "unit_id" => "43925"}, "name" => "Wiltshire Council", "country" => "E", "type_name" => "Unitary Authority", "generation_low" => 11, "country_name" => "England", "type" => "UTA"} }; - # We must make sure we output correctly for testing purposes, we might - # be within a different locale here... - my $json = mySociety::Locale::in_gb_locale { - $self->json->encode($response) }; - return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; + return $self->output($response); + }, + + sub (GET + /areas/*) { + my ($self, $areas) = @_; + if ($areas eq 'Hart') { + $self->output({2333 => {parent_area => undef, id => 2333, name => "Hart District Council", type => "DIS"}}); + } elsif ($areas eq 'Birmingham') { + $self->output({2514 => {parent_area => undef, id => 2514, name => "Birmingham City Council", type => "MTD"}}); + } elsif ($areas eq 'Gloucestershire') { + $self->output({2226 => {parent_area => undef, id => 2226, name => "Gloucestershire County Council", type => "CTY"}}); + } elsif ($areas eq 'Cheltenham') { + $self->output({2326 => {parent_area => undef, id => 2326, name => "Cheltenham Borough Council", type => "DIS"}}); + } elsif ($areas eq 'Lansdown and Park') { + $self->output({22261 => {parent_area => 2226, id => 22261, name => "Lansdown and Park", type => "CED"}}); + } elsif ($areas eq 'Lansdown') { + $self->output({23261 => {parent_area => 2326, id => 23261, name => "Lansdown", type => "DIW"}}); + } elsif ($areas eq 'UTA') { + $self->output({2650 => {parent_area => undef, id => 2650, name => "Aberdeen Council", type => "UTA"}}); + } }, sub (GET + /area/*) { my ($self, $area) = @_; - my $response = {"parent_area" => undef, "generation_high" => 25, "all_names" => {}, "id" => 2245, "codes" => {"ons" => "00HY", "gss" => "E06000054", "unit_id" => "43925"}, "name" => "Wiltshire Council", "country" => "E", "type_name" => "Unitary Authority", "generation_low" => 11, "country_name" => "England", "type" => "UTA"}; - # We must make sure we output correctly for testing purposes, we might - # be within a different locale here... - my $json = mySociety::Locale::in_gb_locale { - $self->json->encode($response) }; - return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; + my $response = { "id" => $area, "name" => "Area $area", "type" => "UTA" }; + return $self->output($response); }, sub (GET + /area/*/children) { @@ -56,19 +98,15 @@ sub dispatch_request { "60705" => { "parent_area" => 2245, "generation_high" => 25, "all_names" => { }, "id" => 60705, "codes" => { "ons" => "00HY226", "gss" => "E04011842", "unit_id" => "17101" }, "name" => "Trowbridge", "country" => "E", "type_name" => "Civil parish/community", "generation_low" => 12, "country_name" => "England", "type" => "CPC" }, "62883" => { "parent_area" => 2245, "generation_high" => 25, "all_names" => { }, "id" => 62883, "codes" => { "ons" => "00HY026", "gss" => "E04011642", "unit_id" => "17205" }, "name" => "Bradford-on-Avon", "country" => "E", "type_name" => "Civil parish/community", "generation_low" => 12, "country_name" => "England", "type" => "CPC" }, }; - # We must make sure we output correctly for testing purposes, we might - # be within a different locale here... - my $json = mySociety::Locale::in_gb_locale { - $self->json->encode($response) }; - return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; + return $self->output($response); }, -} -sub postcode { - my ($self, $postcode) = @_; - return { - wgs84_lat => 51.5, wgs84_lon => -2.1, postcode => $postcode, coordsyst => 'G', - }; + sub (GET + /area/*/example_postcode) { + my ($self, $area) = @_; + return [ 200, [ 'Content-Type' => 'application/json' ], [ '"AB12 1AA"' ] ]; + }, } +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..2fdd8b74a 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; @@ -148,7 +146,7 @@ subtest 'check summary counts' => sub { # This override is wrapped around ALL the /admin/body tests FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', MAPIT_TYPES => [ 'UTA' ], BASE_URL => 'http://www.example.org', }, sub { @@ -580,7 +578,6 @@ foreach my $test ( } FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', ALLOWED_COBRANDS => 'fixmystreet', }, sub { @@ -1204,7 +1201,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/alert.t b/t/app/controller/alert.t index c42eba6b8..cb5949b8f 100644 --- a/t/app/controller/alert.t +++ b/t/app/controller/alert.t @@ -17,7 +17,7 @@ $mech->content_contains('html class="no-js" lang="en-gb"'); # check that we can get list page FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', GEOCODER => '', }, sub { $mech->get_ok('/alert/list'); @@ -25,21 +25,21 @@ FixMyStreet::override_config { $mech->content_contains('Local RSS feeds and email alerts'); $mech->content_contains('html class="no-js" lang="en-gb"'); - $mech->get_ok('/alert/list?pc=EH99 1SP'); + $mech->get_ok('/alert/list?pc=EH1 1BB'); $mech->title_like(qr/^Local RSS feeds and email alerts/); - $mech->content_contains('Here are the types of local problem alerts for ‘EH99 1SP’'); + $mech->content_contains('Here are the types of local problem alerts for ‘EH1 1BB’'); $mech->content_contains('html class="no-js" lang="en-gb"'); $mech->content_contains('Problems within 10.0km'); - $mech->content_contains('rss/pc/EH991SP/2'); - $mech->content_contains('rss/pc/EH991SP/5'); - $mech->content_contains('rss/pc/EH991SP/10'); - $mech->content_contains('rss/pc/EH991SP/20'); - $mech->content_contains('Problems within City of Edinburgh'); + $mech->content_contains('rss/pc/EH11BB/2'); + $mech->content_contains('rss/pc/EH11BB/5'); + $mech->content_contains('rss/pc/EH11BB/10'); + $mech->content_contains('rss/pc/EH11BB/20'); + $mech->content_contains('Problems within Edinburgh City'); $mech->content_contains('Problems within City Centre ward'); - $mech->content_contains('/rss/reports/City+of+Edinburgh'); - $mech->content_contains('/rss/reports/City+of+Edinburgh/City+Centre'); - $mech->content_contains('council:2651:City_of_Edinburgh'); - $mech->content_contains('ward:2651:20728:City_of_Edinburgh:City_Centre'); + $mech->content_contains('/rss/reports/Edinburgh'); + $mech->content_contains('/rss/reports/Edinburgh/City+Centre'); + $mech->content_contains('council:2651:Edinburgh'); + $mech->content_contains('ward:2651:20728:Edinburgh:City_Centre'); subtest "Test Nominatim lookup" => sub { LWP::Protocol::PSGI->register(t::Mock::Nominatim->run_if_script, host => 'nominatim.openstreetmap.org'); diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t index 1b85adf7e..ea38f7c25 100644 --- a/t/app/controller/alert_new.t +++ b/t/app/controller/alert_new.t @@ -208,7 +208,7 @@ foreach my $test ( FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/alert/list?pc=EH991SP'); }; @@ -312,7 +312,7 @@ subtest "Test two-tier council alerts" => sub { ) { FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok( '/alert/list?pc=GL502PR' ); $mech->submit_form_ok( { @@ -351,7 +351,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub { $mech->get_ok( '/alert' ); FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->submit_form_ok( { with_fields => { pc => 'EH11BB' } } ); $mech->submit_form_ok( { @@ -371,7 +371,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub { } } - my $dt = DateTime->now()->add( days => 2); + my $dt = DateTime->now(time_zone => 'Europe/London')->add(days => 2); my $dt_parser = FixMyStreet::App->model('DB')->schema->storage->datetime_parser; @@ -436,7 +436,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub { ok $update, "created test update - $update_id"; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { FixMyStreet::App->model('DB::AlertType')->email_alerts(); }; @@ -447,7 +447,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub { for (@emails) { my $body = $mech->get_text_body_from_email($_); $count++ if $body =~ /The following updates have been left on this report:/; - $count++ if $body =~ /The following new FixMyStreet reports have been added in the City of\s+Edinburgh\s+Council area:/; + $count++ if $body =~ /The following new FixMyStreet reports have been added in the Area 2651 area:/; $count++ if $body =~ /The following FixMyStreet reports have been made within the area you\s+specified:/; $count++ if $body =~ /\s+-\s+Testing/; } @@ -486,7 +486,7 @@ subtest "Test signature template is used from cobrand" => sub { my $user2 = $mech->create_user_ok('alerts@example.com', name => 'Alert User' ); - my $dt = DateTime->now()->add( days => 2); + my $dt = DateTime->now(time_zone => 'Europe/London')->add(days => 2); my $dt_parser = FixMyStreet::App->model('DB')->schema->storage->datetime_parser; @@ -542,7 +542,7 @@ subtest "Test signature template is used from cobrand" => sub { $mech->clear_emails_ok; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], }, sub { FixMyStreet::App->model('DB::AlertType')->email_alerts(); @@ -570,7 +570,7 @@ subtest "Test signature template is used from cobrand" => sub { $mech->clear_emails_ok; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], }, sub { FixMyStreet::App->model('DB::AlertType')->email_alerts(); @@ -665,7 +665,7 @@ for my $test ( $mech->clear_emails_ok; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { FixMyStreet::App->model('DB::AlertType')->email_alerts(); }; @@ -673,7 +673,7 @@ for my $test ( $report->update( { non_public => 0 } ); FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { FixMyStreet::App->model('DB::AlertType')->email_alerts(); }; diff --git a/t/app/controller/around.t b/t/app/controller/around.t index 9e2e7c524..c8aca04aa 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; @@ -17,7 +15,7 @@ subtest "check that if no query we get sent back to the homepage" => sub { subtest "redirect x,y requests to lat/lon (301 - permanent)" => sub { FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/around?x=3281&y=1113'); }; @@ -73,8 +71,8 @@ foreach my $test ( foreach my $test ( { pc => 'SW1A 1AA', - latitude => '51.5', - longitude => '-2.1', + latitude => '51.501009', + longitude => '-0.141588', }, { pc => 'TQ 388 773', @@ -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' => '.' } ], @@ -102,7 +98,7 @@ foreach my $test ( subtest 'check non public reports are not displayed on around page' => sub { my $params = { - postcode => 'EH99 1SP', + postcode => 'EH1 1BB', latitude => 55.9519637512, longitude => -3.17492254484, }; @@ -112,9 +108,9 @@ subtest 'check non public reports are not displayed on around page' => sub { $mech->get_ok('/'); FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { - $mech->submit_form_ok( { with_fields => { pc => 'EH99 1SP' } }, + $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB' } }, "good location" ); }; $mech->content_contains( 'Around page Test 3 for 2651', @@ -126,9 +122,9 @@ subtest 'check non public reports are not displayed on around page' => sub { $mech->get_ok('/'); FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { - $mech->submit_form_ok( { with_fields => { pc => 'EH99 1SP' } }, + $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB' } }, "good location" ); }; $mech->content_lacks( 'Around page Test 3 for 2651', diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t index 22ade6f4b..3a11cfc4a 100644 --- a/t/app/controller/auth.t +++ b/t/app/controller/auth.t @@ -56,6 +56,10 @@ for my $test ( is_deeply $mech->page_errors, [ $error_message ], 'errors match'; } +# Email address parsing should pass from here +my $resolver = Test::MockModule->new('Email::Valid'); +$resolver->mock('address', sub { $_[1] }); + # create a new account $mech->clear_emails_ok; $mech->get_ok('/auth'); diff --git a/t/app/controller/auth_social.t b/t/app/controller/auth_social.t index f3eae32a7..09fdf22d3 100644 --- a/t/app/controller/auth_social.t +++ b/t/app/controller/auth_social.t @@ -1,13 +1,13 @@ use strict; use warnings; use Test::More; +use Test::MockModule; use LWP::Protocol::PSGI; use LWP::Simple; 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 +18,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', @@ -30,6 +28,9 @@ FixMyStreet::override_config { my $fb_email = 'facebook@example.org'; my $fb_uid = 123456789; +my $resolver = Test::MockModule->new('Email::Valid'); +$resolver->mock('address', sub { 'facebook@example.org' }); + 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 { @@ -138,6 +139,8 @@ for my $fb_state ( 'refused', 'no email', 'existing UID', 'okay' ) { } } +$resolver->mock('address', sub { 'twitter@example.org' }); + my $tw_email = 'twitter@example.org'; my $tw_uid = 987654321; diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t index 5ea5cb9f5..903affdcf 100644 --- a/t/app/controller/dashboard.t +++ b/t/app/controller/dashboard.t @@ -25,7 +25,7 @@ my $p_user = $mech->create_user_ok('p_user@example.com'); set_absolute_time('2014-03-01T12:00:00'); FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->not_logged_in_ok; @@ -48,7 +48,7 @@ FixMyStreet::override_config { with_fields => { email => $test_user, password_sign_in => $test_pass } } ); - $mech->content_contains( 'City of Edinburgh' ); + $mech->content_contains( 'Area 2651' ); FixMyStreet::App->model('DB::Contact')->search( { body_id => $body->id } ) ->delete; diff --git a/t/app/controller/index.t b/t/app/controller/index.t index 6752d4d7e..6b28a03d2 100644 --- a/t/app/controller/index.t +++ b/t/app/controller/index.t @@ -12,12 +12,7 @@ subtest "check that the form goes to /around" => sub { $mech->get_ok('/'); is $mech->uri->path, '/', "still on '/'"; - # submit form - FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', - }, sub { - $mech->submit_form_ok( { with_fields => { pc => 'SW1A 1AA', } } ); - }; + $mech->submit_form_ok( { with_fields => { pc => 'SW1A 1AA', } } ); # check that we are at /around is $mech->uri->path, '/around', "Got to /around"; @@ -52,7 +47,7 @@ subtest "does pc, (x,y), (e,n) or (lat,lon) go to /around" => sub { # get the uri and check for 302 FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok($uri); }; diff --git a/t/app/controller/photo.t b/t/app/controller/photo.t index 69c2ae866..ad857b5e3 100644 --- a/t/app/controller/photo.t +++ b/t/app/controller/photo.t @@ -30,7 +30,7 @@ subtest "Check multiple upload worked" => sub { # submit initial pc form FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', UPLOAD_DIR => $UPLOAD_DIR, }, sub { diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t index b4405be57..551a59481 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; @@ -13,7 +11,7 @@ END { FixMyStreet::App->log->enable('info'); } my $mech = FixMyStreet::TestMech->new; -my $body = $mech->create_body_ok(2245, 'Wiltshire Council'); +my $body = $mech->create_body_ok(2237, 'Oxfordshire County Council'); my $contact1 = $mech->create_contact_ok( body_id => $body->id, category => 'Street lighting', email => 'highways@example.com' ); my $contact2 = $mech->create_contact_ok( body_id => $body->id, category => 'Potholes', email => 'potholes@example.com' ); @@ -38,7 +36,7 @@ subtest "Body user, has permission to add report as council" => sub { detail => 'Test report details.', category => 'Street lighting', ); - is $report->name, 'Wiltshire Council', 'report name is body'; + is $report->name, 'Oxfordshire County Council', 'report name is body'; is $report->user->name, 'Body User', 'user name unchanged'; is $report->user->id, $user->id, 'user matches'; is $report->anonymous, 0, 'report not anonymous'; @@ -59,7 +57,7 @@ subtest "Body user, has permission to add report as another user" => sub { is $report->user->name, 'Another User', 'user name matches'; is $report->user->email, 'another@example.net', 'user email correct'; isnt $report->user->id, $user->id, 'user does not match'; - like $mech->get_text_body_from_email, qr/Your report to Wiltshire Council has been logged/; + like $mech->get_text_body_from_email, qr/Your report to Oxfordshire County Council has been logged/; push @users, $report->user; }; @@ -78,7 +76,7 @@ subtest "Body user, has permission to add report as another (existing) user" => is $report->user->name, 'Existing User', 'user name remains same'; is $report->user->email, 'existing@example.net', 'user email correct'; isnt $report->user->id, $user->id, 'user does not match'; - like $mech->get_text_body_from_email, qr/Your report to Wiltshire Council has been logged/; + like $mech->get_text_body_from_email, qr/Your report to Oxfordshire County Council has been logged/; push @users, $report->user; }; @@ -88,7 +86,7 @@ subtest "Body user, has permission to add update as council" => sub { form_as => 'body', update => 'Test Update', ); - is $update->name, 'Wiltshire Council', 'update name is body'; + is $update->name, 'Oxfordshire County Council', 'update name is body'; is $update->user->name, 'Body User', 'user name unchanged'; is $update->user->id, $user->id, 'user matches'; is $update->anonymous, 0, 'update not anonymous'; @@ -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..b956b61ae 100644 --- a/t/app/controller/report_import.t +++ b/t/app/controller/report_import.t @@ -1,13 +1,15 @@ use strict; use warnings; use Test::More; -use LWP::Protocol::PSGI; -use t::Mock::MapIt; use FixMyStreet::TestMech; use FixMyStreet::App; use Web::Scraper; use Path::Class; +use LWP::Protocol::PSGI; +use t::Mock::MapItZurich; + +LWP::Protocol::PSGI->register(t::Mock::MapItZurich->to_psgi_app, host => 'mapit.zurich'); my $mech = FixMyStreet::TestMech->new; $mech->get_ok('/import'); @@ -92,8 +94,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( # @@ -259,7 +259,7 @@ subtest "Submit a correct entry (with location)" => sub { # go to the token url FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok($token_url); }; @@ -285,7 +285,7 @@ subtest "Submit a correct entry (with location)" => sub { # change the details FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->submit_form_ok( # { @@ -318,7 +318,7 @@ subtest "Submit a correct entry (with location)" => sub { subtest "Submit a correct entry (with location) to cobrand" => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'zurich' ], - MAPIT_URL => 'http://global.mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.zurich/', MAPIT_TYPES => [ 'O08' ], MAPIT_ID_WHITELIST => [], MAP_TYPE => 'Zurich,OSM', diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index cc98f2b64..69e43ad99 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -34,7 +34,7 @@ my $user = $mech->log_in_ok('test@example.com'); $user->update( { from_body => $oxon } ); FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', ALLOWED_COBRANDS => 'fixmystreet', }, sub { subtest "test inspect page" => sub { @@ -177,7 +177,6 @@ FixMyStreet::override_config { }; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', ALLOWED_COBRANDS => 'oxfordshire', }, sub { subtest "test negative reputation" => sub { @@ -215,7 +214,6 @@ FixMyStreet::override_config { }; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', ALLOWED_COBRANDS => [ 'oxfordshire', 'fixmystreet' ], BASE_URL => 'http://fixmystreet.site', }, sub { diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index c4dd30e47..fd3108438 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -25,7 +25,7 @@ subtest "test that bare requests to /report/new get redirected" => sub { is_deeply { $mech->uri->query_form }, {}, "query empty"; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/report/new?pc=SW1A%201AA'); }; @@ -476,7 +476,7 @@ foreach my $test ( # submit initial pc form FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } }, "submit location" ); @@ -549,7 +549,7 @@ foreach my $test ( $mech->get_ok('/around'); FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } }, "submit location" ); @@ -665,7 +665,7 @@ subtest "test password errors for a user who is signing in as they report" => su $mech->get_ok('/around'); FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } }, "submit location" ); @@ -717,7 +717,7 @@ subtest "test report creation for a user who is signing in as they report" => su $mech->get_ok('/around'); FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } }, "submit location" ); @@ -813,7 +813,7 @@ foreach my $test ( $mech->get_ok('/around'); FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->submit_form_ok( { with_fields => { pc => 'GL50 2PR', } }, "submit location" ); @@ -912,7 +912,7 @@ subtest "test report creation for a category that is non public" => sub { $mech->get_ok('/around'); FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } }, "submit location" ); @@ -974,7 +974,7 @@ $contact2->update; my $extra_details; FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=' . $saved_lat . '&longitude=' . $saved_lon ); }; @@ -983,7 +983,7 @@ ok !$extra_details->{titles_list}, 'Non Bromley does not send back list of title FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=51.4021&longitude=0.01578'); }; @@ -1003,7 +1003,7 @@ subtest "check that a lat/lon off coast leads to /around" => sub { my $off_coast_longitude = -0.646929; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok( # "/report/new" @@ -1025,7 +1025,7 @@ for my $test ( { desc => 'user title not set if not bromley problem', host => 'www.fixmystreet.com', - postcode => 'EH99 1SP', + postcode => 'EH1 1BB', fms_extra_title => '', extra => [], user_title => undef, @@ -1076,7 +1076,7 @@ for my $test ( subtest $test->{desc} => sub { my $override = { ALLOWED_COBRANDS => [ $test->{host} =~ /bromley/ ? 'bromley' : 'fixmystreet' ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }; $mech->host( $test->{host} ); @@ -1193,9 +1193,9 @@ subtest 'user title not reset if no user title in submission' => sub { $mech->get_ok('/'); FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { - $mech->submit_form_ok( { with_fields => { pc => 'EH99 1SP', } }, + $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } }, "submit location" ); $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, @@ -1258,7 +1258,7 @@ subtest "test Hart" => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'hart', 'fixmystreet' ], BASE_URL => 'http://www.fixmystreet.com', - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/around'); $mech->content_contains( "Hart Council" ); @@ -1434,7 +1434,7 @@ subtest "test SeeSomething" => sub { $mech->get_ok( '/around' ); FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'seesomething' ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->submit_form_ok( { @@ -1481,15 +1481,15 @@ subtest "test SeeSomething" => sub { subtest "categories from deleted bodies shouldn't be visible for new reports" => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { - $mech->get_ok('/report/new/ajax?latitude=51.89&longitude=-2.09'); # Cheltenham + $mech->get_ok('/report/new/ajax?latitude=51.896268&longitude=-2.093063'); # Cheltenham ok $mech->content_contains( $contact3->category ); # Delete the body which the contact belongs to. $contact3->body->update( { deleted => 1 } ); - $mech->get_ok('/report/new/ajax?latitude=51.89&longitude=-2.09'); # Cheltenham + $mech->get_ok('/report/new/ajax?latitude=51.896268&longitude=-2.093063'); # Cheltenham ok $mech->content_lacks( $contact3->category ); $contact3->body->update( { deleted => 0 } ); @@ -1499,12 +1499,12 @@ subtest "categories from deleted bodies shouldn't be visible for new reports" => subtest "unresponsive body handling works" => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { # Test body-level send method my $old_send = $contact1->body->send_method; $contact1->body->update( { send_method => 'Refused' } ); - $mech->get_ok('/report/new/ajax?latitude=55.9&longitude=-3.2'); # Edinburgh + $mech->get_ok('/report/new/ajax?latitude=55.952055&longitude=-3.189579'); # Edinburgh my $body_id = $contact1->body->id; ok $mech->content_like( qr{Edinburgh.*accept reports.*/unresponsive\?body=$body_id} ); @@ -1553,8 +1553,8 @@ subtest "unresponsive body handling works" => sub { phone => '07903 123 456', category => 'Trees', service => 'iOS', - lat => 55.9, - lon => -3.2, + lat => 55.952055, + lon => -3.189579, pc => '', used_map => '1', submit_register => '1', @@ -1580,7 +1580,7 @@ subtest "unresponsive body handling works" => sub { # And test per-category refusing my $old_email = $contact3->email; $contact3->update( { email => 'REFUSED' } ); - $mech->get_ok('/report/new/category_extras?category=Trees&latitude=51.89&longitude=-2.09'); + $mech->get_ok('/report/new/category_extras?category=Trees&latitude=51.896268&longitude=-2.093063'); ok $mech->content_like( qr/Cheltenham.*Trees.*unresponsive.*category=Trees/ ); $mech->get_ok('/around'); @@ -1614,7 +1614,6 @@ subtest "unresponsive body handling works" => sub { subtest "unresponsive body page works" => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', }, sub { my $old_send = $contact1->body->send_method; my $body_id = $contact1->body->id; @@ -1641,7 +1640,7 @@ subtest "extra google analytics code displayed on logged in problem creation" => FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], BASE_URL => 'https://www.fixmystreet.com', - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { # check that the user does not exist my $test_email = 'test-2@example.com'; @@ -1670,7 +1669,7 @@ subtest "extra google analytics code displayed on logged in problem creation" => $mech->submit_form_ok( { with_fields => { - title => "Test Report at café", + title => "Test Report at café", detail => 'Test report details.', photo1 => '', name => 'Joe Bloggs', @@ -1697,7 +1696,7 @@ subtest "extra google analytics code displayed on email confirmation problem cre FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], BASE_URL => 'https://www.fixmystreet.com', - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->log_out_ok; $mech->clear_emails_ok; diff --git a/t/app/controller/report_new_mobile.t b/t/app/controller/report_new_mobile.t index 61cb14a1b..3dfb99b2f 100644 --- a/t/app/controller/report_new_mobile.t +++ b/t/app/controller/report_new_mobile.t @@ -1,5 +1,7 @@ use Test::More; use FixMyStreet::TestMech; +use LWP::Protocol::PSGI; +use t::Mock::MapItZurich; my $mech = FixMyStreet::TestMech->new; @@ -7,10 +9,12 @@ my $mech = FixMyStreet::TestMech->new; FixMyStreet::App->log->disable('info'); END { FixMyStreet::App->log->enable('info'); } +LWP::Protocol::PSGI->register(t::Mock::MapItZurich->to_psgi_app, host => 'mapit.zurich'); + subtest "Check signed up for alert when logged in" => sub { FixMyStreet::override_config { - MAPIT_URL => 'http://global.mapit.mysociety.org', - MAPIT_TYPES => [ 'O06' ], + MAPIT_URL => 'http://mapit.zurich', + MAPIT_TYPES => [ 'O08' ], }, sub { $mech->log_in_ok('user@example.org'); $mech->post_ok( '/report/new/mobile', { diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t index a5b742783..e3a464f88 100644 --- a/t/app/controller/report_new_open311.t +++ b/t/app/controller/report_new_open311.t @@ -12,7 +12,7 @@ END { FixMyStreet::App->log->enable('info'); } my $mech = FixMyStreet::TestMech->new; -my $body = $mech->create_body_ok(2651, 'City of Edinburgh Council'); +my $body = $mech->create_body_ok(2245, 'Wiltshire Council'); $body->update({ endpoint => 'http://example.com/open311', jurisdiction => 'mySociety', @@ -27,7 +27,7 @@ my $contact1 = $mech->create_contact_ok( extra => [ { description => 'Lamppost number', code => 'number', required => 'True' }, { description => 'Lamppost type', code => 'type', required => 'False', values => { value => [ { name => ['Gas'], key => ['old'] }, { name => [ 'Yellow' ], key => [ 'modern' ] } ] } - } + } ], ); my $contact1b = $mech->create_contact_ok( @@ -117,7 +117,7 @@ foreach my $test ( # submit initial pc form FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } }, "submit location" ); @@ -158,7 +158,7 @@ foreach my $test ( }; FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->submit_form_ok( { with_fields => $new_values } ); }; diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t index 8fa03897b..a21d3ad65 100644 --- a/t/app/controller/reports.t +++ b/t/app/controller/reports.t @@ -107,7 +107,7 @@ is $stats->{'Fife Council'}->[4], 3, 'correct number of fixed reports for Fife'; is $stats->{'Fife Council'}->[5], 1, 'correct number of older fixed reports for Fife'; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->follow_link_ok( { text_regex => qr/Birmingham/ } ); $mech->get_ok('/reports/Westminster'); @@ -121,7 +121,7 @@ my $problems = $mech->extract_problem_list; is scalar @$problems, 5, 'correct number of problems displayed'; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/reports'); $mech->follow_link_ok({ url_regex => qr{/reports/Electricity_Gas\+Council} }); @@ -133,7 +133,7 @@ $problems = $mech->extract_problem_list; is scalar @$problems, 2, 'correct number of new problems displayed'; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/reports/City+of+Edinburgh?t=older'); }; @@ -169,7 +169,7 @@ for my $test ( ) { subtest $test->{desc} => sub { FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/reports/Fife+Council?t=' . $test->{type}); }; @@ -183,7 +183,7 @@ my $private = $westminster_problems[2]; ok $private->update( { non_public => 1 } ), 'problem marked non public'; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/reports/Westminster'); }; @@ -213,7 +213,7 @@ subtest "test fiksgatami all reports page" => sub { subtest "test greenwich all reports page" => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'greenwich' ], - MAPIT_URL => 'http://mapit.mysociety.org/' + MAPIT_URL => 'http://mapit.uk/' }, sub { my $body = $mech->create_body_ok(2493, 'Royal Borough of Greenwich'); my $deleted_contact = $mech->create_contact_ok( @@ -235,7 +235,7 @@ subtest "test greenwich all reports page" => sub { subtest "it lists shortlisted reports" => sub { FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/' + MAPIT_URL => 'http://mapit.uk/' }, sub { my $body = FixMyStreet::App->model('DB::Body')->find( $body_edin_id ); my $user = $mech->log_in_ok( 'test@example.com' ); diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t index 4f737dda7..bec504760 100644 --- a/t/app/controller/rss.t +++ b/t/app/controller/rss.t @@ -44,7 +44,7 @@ my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { $mech->host('www.fixmystreet.com'); FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'fixmystreet' ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok("/rss/pc/EH11BB/2"); }; @@ -118,7 +118,7 @@ $report->update(); FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'fixmystreet' ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok("/rss/pc/EH11BB/2"); }; @@ -186,7 +186,7 @@ subtest "check RSS feeds on cobrand have correct URLs for non-cobrand reports" = FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'hart' ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok("/rss/area/Hart"); my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('hart')->new(); diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t index 4e8817225..5e4fcec0a 100644 --- a/t/app/model/alert_type.t +++ b/t/app/model/alert_type.t @@ -188,7 +188,7 @@ subtest "correct text for title after URL" => sub { } )->delete; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { FixMyStreet::DB->resultset('AlertType')->email_alerts(); }; @@ -324,7 +324,7 @@ foreach my $test ( $report->update(); FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { FixMyStreet::DB->resultset('AlertType')->email_alerts(); }; @@ -432,7 +432,7 @@ subtest "check alerts from cobrand send main site url for alerts for different c )->delete; FixMyStreet::override_config { - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { FixMyStreet::DB->resultset('AlertType')->email_alerts(); }; diff --git a/t/app/model/user.t b/t/app/model/user.t index bf73a9d09..d4115d586 100644 --- a/t/app/model/user.t +++ b/t/app/model/user.t @@ -14,7 +14,7 @@ is $problem->user->latest_anonymity, 0, "User's last report was not anonymous"; FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/around?pc=sw1a1aa'); $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" ); @@ -32,7 +32,7 @@ is $problem->user->latest_anonymity, 1, "User's last update was anonymous"; FixMyStreet::override_config { ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], - MAPIT_URL => 'http://mapit.mysociety.org/', + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->get_ok('/around?pc=sw1a1aa'); $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" ); 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" ); |