aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/Mock/Nominatim.pm2
-rw-r--r--t/app/controller/alert.t3
-rw-r--r--t/app/controller/root.t15
-rw-r--r--t/cobrand/bromley.t17
-rw-r--r--t/cobrand/fixamingata.t1
5 files changed, 33 insertions, 5 deletions
diff --git a/t/Mock/Nominatim.pm b/t/Mock/Nominatim.pm
index 1f4e248d2..806ebbfd3 100644
--- a/t/Mock/Nominatim.pm
+++ b/t/Mock/Nominatim.pm
@@ -39,6 +39,6 @@ sub query {
return [];
}
-
+LWP::Protocol::PSGI->register(t::Mock::Nominatim->to_psgi_app, host => 'nominatim.openstreetmap.org');
__PACKAGE__->run_if_script;
diff --git a/t/app/controller/alert.t b/t/app/controller/alert.t
index ce3c2ef9b..57e73e5ec 100644
--- a/t/app/controller/alert.t
+++ b/t/app/controller/alert.t
@@ -1,5 +1,3 @@
-use LWP::Protocol::PSGI;
-
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
@@ -39,7 +37,6 @@ FixMyStreet::override_config {
$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');
$mech->get_ok('/alert/list?pc=High Street');
$mech->content_contains('We found more than one match for that location');
};
diff --git a/t/app/controller/root.t b/t/app/controller/root.t
index ddf659b77..b5f8ba031 100644
--- a/t/app/controller/root.t
+++ b/t/app/controller/root.t
@@ -1,4 +1,5 @@
use FixMyStreet::TestMech;
+use Test::MockModule;
ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' );
@@ -73,4 +74,18 @@ FixMyStreet::override_config {
};
};
+subtest "check_login_disallowed cobrand hook" => sub {
+ warn '#' x 50 . "\n";
+ my $cobrand = Test::MockModule->new('FixMyStreet::Cobrand::Default');
+ $cobrand->mock('check_login_disallowed', sub {
+ my $self = shift;
+ return 0 if $self->{c}->req->path eq 'auth';
+ return 1;
+ }
+ );
+
+ $mech->get_ok('/');
+ is $mech->uri->path_query, '/auth?r=', 'redirects to auth page';
+};
+
done_testing();
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index d62a0ad0f..6ee4be282 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -194,4 +194,21 @@ subtest 'check display of TfL reports' => sub {
$mech->content_like(qr{<a title="Test Test[^>]*bromley.example.org[^>]*><img[^>]*yellow});
};
+subtest 'check geolocation overrides' => sub {
+ my $cobrand = FixMyStreet::Cobrand::Bromley->new;
+ foreach my $test (
+ { query => 'Main Rd, BR1', town => 'Bromley', string => 'Main Rd' },
+ { query => 'Main Rd, BR3', town => 'Beckenham', string => 'Main Rd' },
+ { query => 'Main Rd, BR4', town => 'West Wickham', string => 'Main Rd' },
+ { query => 'Main Rd, BR5', town => 'Orpington', string => 'Main Rd' },
+ { query => 'Main Rd, BR7', town => 'Chislehurst', string => 'Main Rd' },
+ { query => 'Main Rd, BR8', town => 'Swanley', string => 'Main Rd' },
+ { query => 'Old Priory Avenue', town => 'BR6 0PL', string => 'Old Priory Avenue' },
+ ) {
+ my $res = $cobrand->disambiguate_location($test->{query});
+ is $res->{town}, $test->{town}, "Town matches $test->{town}";
+ is $res->{string}, $test->{string}, "String matches $test->{string}";
+ }
+};
+
done_testing();
diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t
index 0aa264660..d1f1dcec4 100644
--- a/t/cobrand/fixamingata.t
+++ b/t/cobrand/fixamingata.t
@@ -5,7 +5,6 @@ use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
use t::Mock::Nominatim;
-LWP::Protocol::PSGI->register(t::Mock::Nominatim->to_psgi_app, host => 'nominatim.openstreetmap.org');
# Front page test