diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-06-14 13:19:09 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-06-14 16:39:36 +0100 |
commit | 46fd6e9bfe5d00230aec44188e66c60e89c416e5 (patch) | |
tree | ef042924605697ab7ed48013e57bb228d41a09f8 | |
parent | 2a6ef907881ff0840f17170c59c973c7943c7943 (diff) |
[Bromley] Include TfL reports on map, in grey.
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bromley.pm | 8 | ||||
-rw-r--r-- | t/cobrand/bromley.t | 34 |
2 files changed, 38 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index 5d14d0b01..36a3e3d5f 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -16,6 +16,13 @@ sub base_url { return 'https://fix.bromley.gov.uk'; } +sub problems_on_map_restriction { + my ($self, $rs) = @_; + return $rs if FixMyStreet->staging_flag('skip_checks'); + my $tfl = FixMyStreet::DB->resultset('Body')->search({ name => 'TfL' })->first; + return $rs->to_body($tfl ? [ $self->body->id, $tfl->id ] : $self->body); +} + sub default_show_name { 0 } sub disambiguate_location { @@ -64,6 +71,7 @@ sub map_type { # Bromley pins always yellow sub pin_colour { my ( $self, $p, $context ) = @_; + return 'grey' if !$self->owns_problem( $p ); return 'yellow'; } diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index b3fb3564b..d62a0ad0f 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -18,8 +18,16 @@ $contact->set_extra_fields( { code => 'service_request_id_ext', datatype => 'number', }, ); $contact->update; +my $tfl = $mech->create_body_ok( 2482, 'TfL'); +$mech->create_contact_ok( + body_id => $tfl->id, + category => 'Traffic Lights', + email => 'tfl@example.org', +); my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', { + latitude => 51.402096, + longitude => 0.015784, cobrand => 'bromley', user => $user, }); @@ -51,8 +59,8 @@ for my $test ( desc => 'testing special Open311 behaviour', updates => {}, expected => { - 'attribute[easting]' => 529025, - 'attribute[northing]' => 179716, + 'attribute[easting]' => 540315, + 'attribute[northing]' => 168935, 'attribute[service_request_id_ext]' => $report->id, 'attribute[report_title]' => 'Test Test 1 for ' . $body->id, 'jurisdiction_id' => 'FMS', @@ -66,8 +74,8 @@ for my $test ( postcode => '' }, expected => { - 'attribute[easting]' => 529025, - 'attribute[northing]' => 179716, + 'attribute[easting]' => 540315, + 'attribute[northing]' => 168935, 'attribute[service_request_id_ext]' => $report->id, 'jurisdiction_id' => 'FMS', 'address_id' => '#NOTPINPOINTED#', @@ -168,4 +176,22 @@ for my $test ( }; } +subtest 'check display of TfL reports' => sub { + $mech->create_problems_for_body( 1, $tfl->id, 'TfL Test', { + latitude => 51.402096, + longitude => 0.015784, + cobrand => 'bromley', + user => $user, + }); + $mech->get_ok( '/report/' . $report->id ); + FixMyStreet::override_config { + ALLOWED_COBRANDS => 'bromley', + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->follow_link_ok({ text_regex => qr/Back to all reports/i }); + }; + $mech->content_like(qr{<a title="TfL Test[^>]*www.example.org[^>]*><img[^>]*grey}); + $mech->content_like(qr{<a title="Test Test[^>]*bromley.example.org[^>]*><img[^>]*yellow}); +}; + done_testing(); |