aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x.cypress/cypress/fixtures/tfl-bus-stops.xml176
-rw-r--r--.cypress/cypress/fixtures/tfl-tlrn.xml13
-rw-r--r--.cypress/cypress/integration/tfl.js37
-rwxr-xr-xbin/browser-tests4
-rwxr-xr-xbin/fixmystreet.com/fixture10
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm11
-rw-r--r--perllib/FixMyStreet/Cobrand/TfL.pm37
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm11
-rw-r--r--t/Mock/MapIt.pm1
-rw-r--r--t/cobrand/tfl.t38
11 files changed, 334 insertions, 8 deletions
diff --git a/.cypress/cypress/fixtures/tfl-bus-stops.xml b/.cypress/cypress/fixtures/tfl-bus-stops.xml
new file mode 100755
index 000000000..145455284
--- /dev/null
+++ b/.cypress/cypress/fixtures/tfl-bus-stops.xml
@@ -0,0 +1,176 @@
+<?xml version='1.0' encoding="UTF-8" ?>
+<wfs:FeatureCollection
+ xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
+ xmlns:gml="http://www.opengis.net/gml"
+ xmlns:wfs="http://www.opengis.net/wfs"
+ xmlns:ogc="http://www.opengis.net/ogc"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://mapserver.gis.umn.edu/mapserver https://tilma.mysociety.org:80/mapserver/tfl?SERVICE=WFS&amp;VERSION=1.1.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=busstops&amp;OUTPUTFORMAT=text/xml;%20subtype=gml/3.1.1 http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
+ <gml:boundedBy>
+ <gml:Envelope srsName="EPSG:3857">
+ <gml:lowerCorner>-26966.052548 6682557.933485</gml:lowerCorner>
+ <gml:upperCorner>-24818.713303 6683455.672461</gml:upperCorner>
+ </gml:Envelope>
+ </gml:boundedBy>
+<!-- WARNING: FeatureId item 'fid' not found in typename 'busstops'. -->
+ <gml:featureMember>
+ <ms:busstops>
+ <gml:boundedBy>
+ <gml:Envelope srsName="EPSG:3857">
+ <gml:lowerCorner>-26739.919949 6682734.390283</gml:lowerCorner>
+ <gml:upperCorner>-26739.919949 6682734.390283</gml:upperCorner>
+ </gml:Envelope>
+ </gml:boundedBy>
+ <ms:msGeometry>
+ <gml:Point srsName="EPSG:3857">
+ <gml:pos>-26739.919949 6682734.390283</gml:pos>
+ </gml:Point>
+ </ms:msGeometry>
+ <ms:STOP_CODE>BP3936</ms:STOP_CODE>
+ </ms:busstops>
+ </gml:featureMember>
+ <gml:featureMember>
+ <ms:busstops>
+ <gml:boundedBy>
+ <gml:Envelope srsName="EPSG:3857">
+ <gml:lowerCorner>-24974.257309 6683105.238970</gml:lowerCorner>
+ <gml:upperCorner>-24974.257309 6683105.238970</gml:upperCorner>
+ </gml:Envelope>
+ </gml:boundedBy>
+ <ms:msGeometry>
+ <gml:Point srsName="EPSG:3857">
+ <gml:pos>-24974.257309 6683105.238970</gml:pos>
+ </gml:Point>
+ </ms:msGeometry>
+ <ms:STOP_CODE>BP3931</ms:STOP_CODE>
+ </ms:busstops>
+ </gml:featureMember>
+ <gml:featureMember>
+ <ms:busstops>
+ <gml:boundedBy>
+ <gml:Envelope srsName="EPSG:3857">
+ <gml:lowerCorner>-24826.301974 6683406.167649</gml:lowerCorner>
+ <gml:upperCorner>-24826.301974 6683406.167649</gml:upperCorner>
+ </gml:Envelope>
+ </gml:boundedBy>
+ <ms:msGeometry>
+ <gml:Point srsName="EPSG:3857">
+ <gml:pos>-24826.301974 6683406.167649</gml:pos>
+ </gml:Point>
+ </ms:msGeometry>
+ <ms:STOP_CODE>BP3929</ms:STOP_CODE>
+ </ms:busstops>
+ </gml:featureMember>
+ <gml:featureMember>
+ <ms:busstops>
+ <gml:boundedBy>
+ <gml:Envelope srsName="EPSG:3857">
+ <gml:lowerCorner>-26021.414677 6682568.040132</gml:lowerCorner>
+ <gml:upperCorner>-26021.414677 6682568.040132</gml:upperCorner>
+ </gml:Envelope>
+ </gml:boundedBy>
+ <ms:msGeometry>
+ <gml:Point srsName="EPSG:3857">
+ <gml:pos>-26021.414677 6682568.040132</gml:pos>
+ </gml:Point>
+ </ms:msGeometry>
+ <ms:STOP_CODE>BP3939</ms:STOP_CODE>
+ </ms:busstops>
+ </gml:featureMember>
+ <gml:featureMember>
+ <ms:busstops>
+ <gml:boundedBy>
+ <gml:Envelope srsName="EPSG:3857">
+ <gml:lowerCorner>-24818.713303 6683455.672461</gml:lowerCorner>
+ <gml:upperCorner>-24818.713303 6683455.672461</gml:upperCorner>
+ </gml:Envelope>
+ </gml:boundedBy>
+ <ms:msGeometry>
+ <gml:Point srsName="EPSG:3857">
+ <gml:pos>-24818.713303 6683455.672461</gml:pos>
+ </gml:Point>
+ </ms:msGeometry>
+ <ms:STOP_CODE>BP3930</ms:STOP_CODE>
+ </ms:busstops>
+ </gml:featureMember>
+ <gml:featureMember>
+ <ms:busstops>
+ <gml:boundedBy>
+ <gml:Envelope srsName="EPSG:3857">
+ <gml:lowerCorner>-25376.237114 6682675.840759</gml:lowerCorner>
+ <gml:upperCorner>-25376.237114 6682675.840759</gml:upperCorner>
+ </gml:Envelope>
+ </gml:boundedBy>
+ <ms:msGeometry>
+ <gml:Point srsName="EPSG:3857">
+ <gml:pos>-25376.237114 6682675.840759</gml:pos>
+ </gml:Point>
+ </ms:msGeometry>
+ <ms:STOP_CODE>BP3934</ms:STOP_CODE>
+ </ms:busstops>
+ </gml:featureMember>
+ <gml:featureMember>
+ <ms:busstops>
+ <gml:boundedBy>
+ <gml:Envelope srsName="EPSG:3857">
+ <gml:lowerCorner>-26966.052548 6682770.284294</gml:lowerCorner>
+ <gml:upperCorner>-26966.052548 6682770.284294</gml:upperCorner>
+ </gml:Envelope>
+ </gml:boundedBy>
+ <ms:msGeometry>
+ <gml:Point srsName="EPSG:3857">
+ <gml:pos>-26966.052548 6682770.284294</gml:pos>
+ </gml:Point>
+ </ms:msGeometry>
+ <ms:STOP_CODE>BP3935</ms:STOP_CODE>
+ </ms:busstops>
+ </gml:featureMember>
+ <gml:featureMember>
+ <ms:busstops>
+ <gml:boundedBy>
+ <gml:Envelope srsName="EPSG:3857">
+ <gml:lowerCorner>-26068.008727 6682557.933485</gml:lowerCorner>
+ <gml:upperCorner>-26068.008727 6682557.933485</gml:upperCorner>
+ </gml:Envelope>
+ </gml:boundedBy>
+ <ms:msGeometry>
+ <gml:Point srsName="EPSG:3857">
+ <gml:pos>-26068.008727 6682557.933485</gml:pos>
+ </gml:Point>
+ </ms:msGeometry>
+ <ms:STOP_CODE>BP3938</ms:STOP_CODE>
+ </ms:busstops>
+ </gml:featureMember>
+ <gml:featureMember>
+ <ms:busstops>
+ <gml:boundedBy>
+ <gml:Envelope srsName="EPSG:3857">
+ <gml:lowerCorner>-25333.074328 6682676.397427</gml:lowerCorner>
+ <gml:upperCorner>-25333.074328 6682676.397427</gml:upperCorner>
+ </gml:Envelope>
+ </gml:boundedBy>
+ <ms:msGeometry>
+ <gml:Point srsName="EPSG:3857">
+ <gml:pos>-25333.074328 6682676.397427</gml:pos>
+ </gml:Point>
+ </ms:msGeometry>
+ <ms:STOP_CODE>BP3933</ms:STOP_CODE>
+ </ms:busstops>
+ </gml:featureMember>
+ <gml:featureMember>
+ <ms:busstops>
+ <gml:boundedBy>
+ <gml:Envelope srsName="EPSG:3857">
+ <gml:lowerCorner>-24959.726550 6683177.005692</gml:lowerCorner>
+ <gml:upperCorner>-24959.726550 6683177.005692</gml:upperCorner>
+ </gml:Envelope>
+ </gml:boundedBy>
+ <ms:msGeometry>
+ <gml:Point srsName="EPSG:3857">
+ <gml:pos>-24959.726550 6683177.005692</gml:pos>
+ </gml:Point>
+ </ms:msGeometry>
+ <ms:STOP_CODE>BP3932</ms:STOP_CODE>
+ </ms:busstops>
+ </gml:featureMember>
+</wfs:FeatureCollection> \ No newline at end of file
diff --git a/.cypress/cypress/fixtures/tfl-tlrn.xml b/.cypress/cypress/fixtures/tfl-tlrn.xml
new file mode 100644
index 000000000..6b99ecddd
--- /dev/null
+++ b/.cypress/cypress/fixtures/tfl-tlrn.xml
@@ -0,0 +1,13 @@
+<?xml version='1.0' encoding="UTF-8" ?>
+<wfs:FeatureCollection
+ xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
+ xmlns:gml="http://www.opengis.net/gml"
+ xmlns:wfs="http://www.opengis.net/wfs"
+ xmlns:ogc="http://www.opengis.net/ogc"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://mapserver.gis.umn.edu/mapserver https://tilma.mysociety.org:80/mapserver/highways?SERVICE=WFS&amp;VERSION=1.1.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=Highways&amp;OUTPUTFORMAT=text/xml;%20subtype=gml/3.1.1 http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
+ <gml:boundedBy>
+ <gml:Null>missing</gml:Null>
+ </gml:boundedBy>
+</wfs:FeatureCollection>
+
diff --git a/.cypress/cypress/integration/tfl.js b/.cypress/cypress/integration/tfl.js
new file mode 100644
index 000000000..7853f26e0
--- /dev/null
+++ b/.cypress/cypress/integration/tfl.js
@@ -0,0 +1,37 @@
+it('allows bus stop clicking outside London', function() {
+ cy.server();
+ cy.route('/report/new/ajax*').as('report-ajax');
+ cy.fixture('tfl-bus-stops.xml');
+ cy.route('**/mapserver/tfl*busstops*', 'fixture:tfl-bus-stops.xml').as('tfl-bus-stops');
+ cy.route('**/mapserver/tfl*RedRoutes*', 'fixture:tfl-tlrn.xml').as('tfl-tlrn');
+
+ // Click on a bus stop outside London...
+ cy.visit('http://tfl.localhost:3001/report/new?latitude=51.345714&longitude=-0.227959');
+ cy.wait('@report-ajax');
+ cy.contains('Transport for London');
+ cy.get('[id=category_group]').select('Bus Stops and Shelters');
+ cy.wait('@tfl-bus-stops');
+ cy.get('.js-subcategory').select('Incorrect timetable');
+
+ // Also check a category not on a red route
+ cy.get('[id=category_group]').select('Mobile Crane Operation');
+ cy.contains('does not maintain this road');
+});
+
+it('does not show TfL categories outside London on .com', function() {
+ cy.visit('http://fixmystreet.localhost:3001/report/new?latitude=51.345714&longitude=-0.227959');
+ cy.contains('We do not yet have details');
+});
+
+it('shows TfL categories inside London on .com', function() {
+ cy.server();
+ cy.route('/report/new/ajax*').as('report-ajax');
+
+ cy.visit('http://fixmystreet.localhost:3001/');
+ cy.get('[name=pc]').type('TW7 5JN');
+ cy.get('[name=pc]').parents('form').submit();
+ cy.get('#map_box').click(290, 307);
+ cy.wait('@report-ajax');
+ cy.get('[id=category_group]').select('Bus Stops and Shelters');
+ cy.get('[id=category_group]').select('Potholes');
+});
diff --git a/bin/browser-tests b/bin/browser-tests
index 04b019880..c7e5df27c 100755
--- a/bin/browser-tests
+++ b/bin/browser-tests
@@ -11,7 +11,7 @@ my ($cobrand, $coords, $area_id, $name, $mapit_url);
BEGIN {
$config_file = 'conf/general.yml-example';
- $cobrand = [ 'borsetshire', 'fixmystreet', 'northamptonshire', 'bathnes', 'buckinghamshire', 'hounslow', 'isleofwight', 'peterborough' ];
+ $cobrand = [ 'borsetshire', 'fixmystreet', 'northamptonshire', 'bathnes', 'buckinghamshire', 'hounslow', 'isleofwight', 'peterborough', 'tfl' ];
$coords = '51.532851,-2.284277';
$area_id = 2608;
$name = 'Borsetshire';
@@ -150,7 +150,7 @@ browser-tests [running options] [fixture options] [cypress options]
--help this help message
Fixture option:
- --cobrand Cobrand(s) to use, default is fixmystreet,northamptonshire,bathnes,buckinghamshire,isleofwight,peterborough
+ --cobrand Cobrand(s) to use, default is fixmystreet,northamptonshire,bathnes,buckinghamshire,isleofwight,peterborough,tfl
--coords Default co-ordinates for created reports
--area_id Area ID to use for created body
--name Name to use for created body
diff --git a/bin/fixmystreet.com/fixture b/bin/fixmystreet.com/fixture
index 53e0b142d..9c471a941 100755
--- a/bin/fixmystreet.com/fixture
+++ b/bin/fixmystreet.com/fixture
@@ -101,6 +101,7 @@ if ($opt->test_fixtures) {
{ area_id => 2483, categories => [ 'Potholes', 'Other' ], name => 'Hounslow Borough Council' },
{ area_id => 2636, categories => [ 'Potholes', 'Private', 'Extra' ], name => 'Isle of Wight Council' },
{ area_id => 2566, categories => [ 'Fallen branch' ], name => 'Peterborough City Council' },
+ { area_id => 2498, categories => [ 'Incorrect timetable', 'Glass broken', 'Mobile Crane Operation' ], name => 'TfL' },
) {
$bodies->{$_->{area_id}} = FixMyStreet::DB::Factory::Body->find_or_create($_);
my $cats = join(', ', @{$_->{categories}});
@@ -223,6 +224,15 @@ if ($opt->test_fixtures) {
}
);
$child_cat->update;
+
+ FixMyStreet::DB->resultset('BodyArea')->create({ body_id => $bodies->{2498}->id, area_id => 2457 });
+ FixMyStreet::DB->resultset('BodyArea')->create({ body_id => $bodies->{2498}->id, area_id => 2483 });
+ $child_cat = FixMyStreet::DB->resultset("Contact")->find({ body => $bodies->{2498}, category => 'Incorrect timetable' });
+ $child_cat->set_extra_metadata(group => ['Bus Stops and Shelters']);
+ $child_cat->update;
+ $child_cat = FixMyStreet::DB->resultset("Contact")->find({ body => $bodies->{2498}, category => 'Glass broken' });
+ $child_cat->set_extra_metadata(group => ['Bus Stops and Shelters']);
+ $child_cat->update;
}
FixMyStreet::DB::Factory::ResponseTemplate->create({
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index a3df4aa82..14aa7b83e 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -688,6 +688,8 @@ sub setup_categories_and_bodies : Private {
my @bodies = $c->model('DB::Body')->active->for_areas(keys %$all_areas)->all;
my %bodies = map { $_->id => $_ } @bodies;
+ $c->cobrand->call_hook(munge_report_new_bodies => \%bodies);
+
my $contacts #
= $c #
->model('DB::Contact') #
@@ -774,7 +776,7 @@ sub setup_categories_and_bodies : Private {
$c->stash->{bodies} = \%bodies;
$c->stash->{contacts} = \@contacts;
$c->stash->{bodies_to_list} = \%bodies_to_list;
- $c->stash->{bodies_ids} = [ map { $_->id } @bodies];
+ $c->stash->{bodies_ids} = [ map { $_ } keys %bodies ];
$c->stash->{category_options} = \@category_options;
$c->stash->{category_extras} = \%category_extras;
$c->stash->{category_extras_hidden} = \%category_extras_hidden;
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index ba82949c7..9ab804c9f 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -83,6 +83,17 @@ sub munge_reports_categories_list {
}
}
+sub munge_report_new_bodies {
+ my ($self, $bodies) = @_;
+
+ my %bodies = map { $_->name => 1 } values %$bodies;
+ if ( $bodies{'TfL'} ) {
+ # Presented categories vary if we're on/off a red route
+ my $tfl = FixMyStreet::Cobrand->get_class_for_moniker( 'tfl' )->new({ c => $self->{c} });
+ $tfl->munge_surrounding_london($bodies);
+ }
+}
+
sub munge_report_new_contacts {
my ($self, $contacts) = @_;
diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm
index 1fa0aabe0..96f1d446d 100644
--- a/perllib/FixMyStreet/Cobrand/TfL.pm
+++ b/perllib/FixMyStreet/Cobrand/TfL.pm
@@ -10,16 +10,29 @@ use FixMyStreet::MapIt;
use mySociety::ArrayUtils;
use Utils;
-sub council_area_id { return [
+sub london_boroughs { (
2511, 2489, 2494, 2488, 2482, 2505, 2512, 2481, 2484, 2495,
2493, 2508, 2502, 2509, 2487, 2485, 2486, 2483, 2507, 2503,
2480, 2490, 2492, 2500, 2510, 2497, 2499, 2491, 2498, 2506,
- 2496, 2501, 2504
-]; }
+ 2496, 2501, 2504,
+) }
+
+# Surrounding areas for bus stops which can be outside London
+sub surrounding_london { (
+ # Clockwise from top left: South Bucks, Three Rivers, Watford, Hertsmere,
+ # Welwyn Hatfield, Broxbourne, Epping Forest, Brentwood, Thurrock,
+ # Dartford, Sevenoaks, Tandridge, Reigate and Banstead, Epsom and Ewell,
+ # Mole Valley, Elmbridge, Spelthorne, Slough
+ 2256, 2338, 2346, 2339, 2344, 2340, 2311, 2309, 2615,
+ 2358, 2350, 2448, 2453, 2457, 2454, 2455, 2456, 2606,
+) }
+
+sub council_area_id { [ $_[0]->london_boroughs, $_[0]->surrounding_london ] }
+
sub council_area { return 'TfL'; }
sub council_name { return 'TfL'; }
sub council_url { return 'tfl'; }
-sub area_types { [ 'LBO' ] }
+sub area_types { [ 'LBO', 'UTA', 'DIS' ] }
sub is_council { 0 }
sub borough_for_report {
@@ -205,7 +218,9 @@ sub state_groups_inspect {
sub fetch_area_children {
my $self = shift;
- my $areas = FixMyStreet::MapIt::call('areas', $self->area_types);
+ # This is for user admin display, in testing can only be London (for MapIt mock)
+ my $ids = FixMyStreet->test_mode ? 'LBO' : $self->council_area_id;
+ my $areas = FixMyStreet::MapIt::call('areas', $ids);
foreach (keys %$areas) {
$areas->{$_}->{name} =~ s/\s*(Borough|City|District|County) Council$//;
}
@@ -454,6 +469,18 @@ sub report_new_is_on_tlrn {
}
sub munge_report_new_contacts { }
+sub munge_report_new_bodies { }
+
+sub munge_surrounding_london {
+ my ($self, $bodies) = @_;
+ # Are we in a London borough?
+ my $all_areas = $self->{c}->stash->{all_areas};
+ my %london_hash = map { $_ => 1 } $self->london_boroughs;
+ if (!grep { $london_hash{$_} } keys %$all_areas) {
+ # Don't send any TfL categories
+ %$bodies = map { $_->id => $_ } grep { $_->name ne 'TfL' } values %$bodies;
+ }
+}
sub munge_red_route_categories {
my ($self, $contacts) = @_;
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 60cecd0bb..6709ef565 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -291,6 +291,17 @@ sub prefill_report_fields_for_inspector { 1 }
sub social_auth_disabled { 1 }
+sub munge_report_new_bodies {
+ my ($self, $bodies) = @_;
+
+ my %bodies = map { $_->name => 1 } values %$bodies;
+ if ( $bodies{'TfL'} ) {
+ # Presented categories vary if we're on/off a red route
+ my $tfl = FixMyStreet::Cobrand->get_class_for_moniker( 'tfl' )->new({ c => $self->{c} });
+ $tfl->munge_surrounding_london($bodies);
+ }
+}
+
sub munge_report_new_contacts {
my ($self, $contacts) = @_;
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index 7dafb7af5..d50ebdc1d 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -46,6 +46,7 @@ my @PLACES = (
[ 'TW7 5JN', 51.482286, -0.328163, 2483, 'Hounslow Borough Council', 'LBO' ],
[ '?', 51.48111, -0.327219, 2483, 'Hounslow Borough Council', 'LBO' ],
[ '?', 51.482045, -0.327219, 2483, 'Hounslow Borough Council', 'LBO' ],
+ [ '?', 51.345714, -0.227959, 2457, 'Epsom and Ewell Borough Council', 'DIS' ],
[ 'CW11 1HZ', 53.145324, -2.370437, 21069, 'Cheshire East Council', 'UTA', 135301, 'Sandbach Town', 'UTW' ],
[ '?', 50.78301, -0.646929 ],
[ 'TA1 1QP', 51.023569, -3.099055, 2239, 'Somerset County Council', 'CTY', 2429, 'Taunton Deane Borough Council', 'DIS' ],
diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t
index cdf3b1bab..8ddc3d671 100644
--- a/t/cobrand/tfl.t
+++ b/t/cobrand/tfl.t
@@ -19,6 +19,10 @@ FixMyStreet::DB->resultset('BodyArea')->find_or_create({
area_id => 2483, # Hounslow
body_id => $body->id,
});
+FixMyStreet::DB->resultset('BodyArea')->find_or_create({
+ area_id => 2457, # Epsom Ewell, outside London, for bus stop test
+ body_id => $body->id,
+});
my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super User', is_superuser => 1);
my $staffuser = $mech->create_user_ok('counciluser@example.com', name => 'Council User', from_body => $body, password => 'password');
$staffuser->user_body_permissions->create({
@@ -341,6 +345,40 @@ subtest "test report creation and reference number" => sub {
is $report->bodies_str, $body->id;
is $report->name, 'Joe Bloggs';
+};
+
+subtest "test bus report creation outside London, .com" => sub {
+ $mech->host('www.fixmystreet.com');
+ $mech->get_ok('/report/new?latitude=51.345714&longitude=-0.227959');
+ $mech->content_lacks('Bus things');
+ $mech->host('tfl.fixmystreet.com');
+};
+
+subtest "test bus report creation outside London" => sub {
+ $mech->get_ok('/report/new?latitude=51.345714&longitude=-0.227959');
+ $mech->submit_form_ok(
+ {
+ with_fields => {
+ # A bus stop in East Ewell
+ latitude => 51.345714,
+ longitude => -0.227959,
+ title => 'Test outwith London',
+ detail => 'Test report details.',
+ name => 'Joe Bloggs',
+ may_show_name => '1',
+ category => 'Bus stops',
+ }
+ },
+ "submit good details"
+ );
+ $mech->content_contains('Your issue is on its way to Transport for London');
+ is_deeply $mech->page_errors, [], "check there were no errors";
+
+ my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test outwith London'});
+ ok $report, "Found the report";
+ is $report->state, 'confirmed', "report confirmed";
+ is $report->bodies_str, $body->id;
+ $report->delete;
$mech->log_out_ok;
};