diff options
author | M Somerville <matthew-github@dracos.co.uk> | 2019-06-07 14:25:41 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-06-07 17:16:16 +0100 |
commit | 9f82fbb4088e32a3ca636a5ccc1e7495e34e73e5 (patch) | |
tree | e96948127aa041161bac617c336345138eb95fac | |
parent | 2f6b889481265549a729ad78f63fc8d1660c126f (diff) |
[Hounslow] Hide TfL Traffic Lights category.
It is handled by an existing category.
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 9 | ||||
-rw-r--r-- | t/cobrand/hounslow.t | 22 |
2 files changed, 31 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm index fb454f495..e01f3e23b 100644 --- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm +++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm @@ -39,6 +39,15 @@ sub restriction { return {}; } +sub munge_category_list { + my ($self, $options, $contacts, $extras) = @_; + + # No TfL Traffic Lights category in Hounslow + my %bodies = map { $_->body->name => 1 } @$contacts; + return unless $bodies{'Hounslow Borough Council'}; + @$options = grep { ($_->{category} || $_->category) !~ /^Traffic lights$/i } @$options; +} + sub title_list { my $self = shift; my $areas = shift; diff --git a/t/cobrand/hounslow.t b/t/cobrand/hounslow.t index 5d9f022e7..417bc7736 100644 --- a/t/cobrand/hounslow.t +++ b/t/cobrand/hounslow.t @@ -3,6 +3,18 @@ use FixMyStreet::TestMech; ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); my $hounslow_id = $mech->create_body_ok(2483, 'Hounslow Borough Council')->id; +$mech->create_contact_ok( + body_id => $hounslow_id, + category => 'Potholes', + email => 'pothole@example.org', +); + +my $tfl = $mech->create_body_ok( 2483, 'TfL'); +$mech->create_contact_ok( + body_id => $tfl->id, + category => 'Traffic lights', + email => 'tfl@example.org', +); $mech->create_problems_for_body(1, $hounslow_id, 'An old problem made before Hounslow FMS launched', { confirmed => '2018-12-25 09:00', @@ -41,4 +53,14 @@ subtest "it does not show old reports on Hounslow" => sub { }; }; +subtest "does not show TfL traffic lights category" => sub { + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + ALLOWED_COBRANDS => 'fixmystreet', + }, sub { + my $json = $mech->get_ok_json('/report/new/ajax?latitude=51.482286&longitude=-0.328163'); + is $json->{by_category}{"Traffic lights"}, undef; + }; +}; + done_testing(); |