diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-04-08 13:12:37 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2016-04-20 13:07:01 +0100 |
commit | 7f2cfbe679ae0c97a7bad63a8554ce4745f541ad (patch) | |
tree | 2673507d6bfd42c3ae599872109e506bb39ca557 | |
parent | d04f0f466f74e2fb6caab2da259664f5eb02079e (diff) |
Cope with a '/' in body name in body slug.
Fixes #574.
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/EmptyHomes.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UK.pm | 2 | ||||
-rw-r--r-- | t/app/controller/reports.t | 5 |
4 files changed, 8 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index c76ee0f7d..6ba144f0d 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -625,6 +625,7 @@ sub short_name { my ($area) = @_; my $name = $area->{name} || $area->name; + $name =~ tr{/}{_}; $name = URI::Escape::uri_escape_utf8($name); $name =~ s/%20/+/g; return $name; diff --git a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm index 995c39c85..70c3c9469 100644 --- a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm +++ b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm @@ -81,7 +81,7 @@ sub short_name { $name =~ s/ (Borough|City|District|County) Council$//; $name =~ s/ Council$//; $name =~ s/ & / and /; - $name =~ s{/}{_}g; + $name =~ tr{/}{_}; $name = URI::Escape::uri_escape_utf8($name); $name =~ s/%20/-/g; return $name; diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm index c33b39aac..0eff48b00 100644 --- a/perllib/FixMyStreet/Cobrand/UK.pm +++ b/perllib/FixMyStreet/Cobrand/UK.pm @@ -109,7 +109,7 @@ sub short_name { $name =~ s/ (Borough|City|District|County) Council$//; $name =~ s/ Council$//; $name =~ s/ & / and /; - $name =~ s{/}{_}g; + $name =~ tr{/}{_}; $name = URI::Escape::uri_escape_utf8($name); $name =~ s/%20/+/g; return $name; diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t index 02625fcc7..9b446174d 100644 --- a/t/app/controller/reports.t +++ b/t/app/controller/reports.t @@ -12,6 +12,7 @@ $mech->create_body_ok(2514, 'Birmingham City Council'); my $body_edin_id = $mech->create_body_ok(2651, 'City of Edinburgh Council')->id; my $body_west_id = $mech->create_body_ok(2504, 'Westminster City Council')->id; my $body_fife_id = $mech->create_body_ok(2649, 'Fife Council')->id; +my $body_slash_id = $mech->create_body_ok(10000, 'Electricity/Gas Council')->id; $mech->delete_problems_for_body( $body_west_id ); $mech->delete_problems_for_body( $body_edin_id ); @@ -122,6 +123,10 @@ is scalar @$problems, 5, 'correct number of problems displayed'; FixMyStreet::override_config { MAPIT_URL => 'http://mapit.mysociety.org/', }, sub { + $mech->get_ok('/reports'); + $mech->follow_link_ok({ url_regex => qr{/reports/Electricity_Gas\+Council} }); + is $mech->uri->path, '/reports/Electricity_Gas+Council', 'Path is correct'; + $mech->get_ok('/reports/City+of+Edinburgh?t=new'); }; $problems = $mech->extract_problem_list; |