diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 5 | ||||
-rw-r--r-- | t/Mock/MapIt.pm | 4 | ||||
-rw-r--r-- | t/app/controller/reports.t | 15 |
3 files changed, 13 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 005397fda..356578bb0 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -392,10 +392,11 @@ sub ward_check : Private { my $qw = mySociety::MaPit::call('area/children', [ $parent_id ], type => $c->cobrand->area_types_children, ); - my %names = map { $_ => 1 } @wards; + my %names = map { $c->cobrand->short_name({ name => $_ }) => 1 } @wards; my @areas; foreach my $area (sort { $a->{name} cmp $b->{name} } values %$qw) { - push @areas, $area if $names{$area->{name}}; + my $name = $c->cobrand->short_name($area); + push @areas, $area if $names{$name}; } if (@areas) { $c->stash->{ward} = $areas[0] if @areas == 1; diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index 315b4fe9f..ea00a7ff0 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -113,8 +113,8 @@ sub dispatch_request { my ($self, $area) = @_; if ($area eq '2514') { return $self->output({ - 8794 => {parent_area => 2514, id => 8794, name => "Aston", type => "MTW"}, - 8773 => {parent_area => 2514, id => 8773, name => "Bournville", type => "MTW"}, + 151907 => {parent_area => 2514, id => 151907, name => "Bordesley & Highgate", type => "MTW"}, + 151942 => {parent_area => 2514, id => 151942, name => "Birchfield", type => "MTW"}, }); } if ($area eq '2326') { diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t index 8cdfddd1b..c57b15a8e 100644 --- a/t/app/controller/reports.t +++ b/t/app/controller/reports.t @@ -115,19 +115,20 @@ $mech->content_contains('5,9,10,22'); $mech->content_contains('2,3,4,4'); FixMyStreet::override_config { + ALLOWED_COBRANDS => 'fixmystreet', MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->submit_form_ok( { with_fields => { body => $body_edin_id } }, 'Submitted dropdown okay' ); - is $mech->uri->path, '/reports/City+of+Edinburgh+Council'; + is $mech->uri->path, '/reports/City+of+Edinburgh'; subtest "test ward pages" => sub { $mech->get_ok('/reports/Birmingham/Bad-Ward'); - is $mech->uri->path, '/reports/Birmingham+City+Council'; - $mech->get_ok('/reports/Birmingham/Aston'); - is $mech->uri->path, '/reports/Birmingham+City+Council/Aston'; - $mech->get_ok('/reports/Birmingham/Aston|Bournville'); - is $mech->uri->path, '/reports/Birmingham+City+Council/Aston%7CBournville'; - $mech->content_contains('Aston, Bournville'); + is $mech->uri->path, '/reports/Birmingham'; + $mech->get_ok('/reports/Birmingham/Bordesley+and+Highgate'); + is $mech->uri->path, '/reports/Birmingham/Bordesley+and+Highgate'; + $mech->get_ok('/reports/Birmingham/Bordesley+and+Highgate|Birchfield'); + is $mech->uri->path, '/reports/Birmingham/Bordesley+and+Highgate%7CBirchfield'; + $mech->content_contains('Birchfield, Bordesley & Highgate'); }; $mech->get_ok('/reports/Westminster'); |