diff options
-rw-r--r-- | perllib/FixMyStreet/Cobrand/TfL.pm | 14 | ||||
-rw-r--r-- | t/Mock/MapIt.pm | 5 | ||||
-rw-r--r-- | t/cobrand/tfl.t | 16 |
3 files changed, 35 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm index b20c2c938..6f5cec730 100644 --- a/perllib/FixMyStreet/Cobrand/TfL.pm +++ b/perllib/FixMyStreet/Cobrand/TfL.pm @@ -4,6 +4,10 @@ use parent 'FixMyStreet::Cobrand::Whitelabel'; use strict; use warnings; +use POSIX qw(strcoll); + +use FixMyStreet::MapIt; + sub council_area_id { return [ 2511, 2489, 2494, 2488, 2482, 2505, 2512, 2481, 2484, 2495, 2493, 2508, 2502, 2509, 2487, 2485, 2486, 2483, 2507, 2503, @@ -96,4 +100,14 @@ sub admin_allow_user { return $user->from_body->name eq 'TfL'; } +sub fetch_area_children { + my $self = shift; + + my $areas = FixMyStreet::MapIt::call('areas', $self->area_types); + foreach (keys %$areas) { + $areas->{$_}->{name} =~ s/\s*(Borough|City|District|County) Council$//; + } + return $areas; +} + 1; diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index 3b36b52f4..96be429e4 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -119,6 +119,11 @@ sub dispatch_request { $self->output({2650 => {parent_area => undef, id => 2650, name => "Aberdeen Council", type => "UTA"}}); } elsif ($areas eq 'GRE') { $self->output({2493 => {parent_area => undef, id => 2493, name => "Greenwich Borough Council", type => "LBO"}}); + } elsif ($areas eq 'LBO') { + $self->output({ + 2482 => {parent_area => undef, id => 2482, name => "Bromley Borough Council", type => "LBO"}, + 2483 => {parent_area => undef, id => 2483, name => "Hounslow Borough Council", type => "LBO"}, + }); } elsif ($areas eq 60705) { $self->output({60705 => {parent_area => 2245, id => 60705, name => "Trowbridge", type => "CPC"}}); } diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t index bb074a872..c7db294ac 100644 --- a/t/cobrand/tfl.t +++ b/t/cobrand/tfl.t @@ -9,6 +9,7 @@ END { FixMyStreet::App->log->enable('info'); } my $mech = FixMyStreet::TestMech->new; my $body = $mech->create_body_ok(2482, 'TfL'); +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); $staffuser->user_body_permissions->create({ body => $body, @@ -155,6 +156,21 @@ subtest 'check report age on /around' => sub { $mech->content_lacks($report->title); }; +subtest 'TfL admin allows inspectors to be assigned to borough areas' => sub { + $mech->log_in_ok($superuser->email); + + $mech->get_ok("/admin/users/" . $staffuser->id) or diag $mech->content; + + $mech->submit_form_ok( { with_fields => { + area_ids => [2482], + } } ); + + $staffuser->discard_changes; + is_deeply $staffuser->area_ids, [2482], "User assigned to Bromley LBO area"; + + $staffuser->update({ area_ids => undef}); # so login below doesn't break +}; + subtest 'TfL staff can access TfL admin' => sub { $mech->log_in_ok( $staffuser->email ); $mech->get_ok('/admin'); |