aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm2
-rw-r--r--t/app/controller/around.t21
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js6
4 files changed, 23 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0df3dda3e..70bd975cf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@
- Front end improvements:
- Include "SameSite=Lax" with all cookies.
- Bugfixes:
+ - Fix bug specifying category in URL on /around. #1950
+ - Fix bug with multiple select-multiples on a page. #1951
- Make sure dashboard filters all fit onto one line.
- Fix issue with red bars on bar graph of many categories.
- Prefetch translations in /reports list of bodies.
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 7cef7ccaa..e4932ecd5 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -240,7 +240,7 @@ sub check_and_stash_category : Private {
)->all;
my @categories = map { { name => $_->category, value => $_->category_display } } @contacts;
$c->stash->{filter_categories} = \@categories;
- my %categories_mapped = map { $_ => 1 } @categories;
+ my %categories_mapped = map { $_->{name} => 1 } @categories;
my $categories = [ $c->get_param_list('filter_category', 1) ];
my %valid_categories = map { $_ => 1 } grep { $_ && $categories_mapped{$_} } @$categories;
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index d1254edb7..618998513 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -137,25 +137,28 @@ subtest 'check non public reports are not displayed on around page' => sub {
};
-subtest 'check category and status filtering works on /around?ajax' => sub {
+subtest 'check category and status filtering works on /around' => sub {
+ my $body = $mech->create_body_ok(2237, "Oxfordshire");
+
my $categories = [ 'Pothole', 'Vegetation', 'Flytipping' ];
my $params = {
- postcode => 'OX1 1ND',
- latitude => 51.7435918829363,
- longitude => -1.23201966270446,
+ postcode => 'OX20 1SZ',
+ latitude => 51.754926,
+ longitude => -1.256179,
};
my $bbox = ($params->{longitude} - 0.01) . ',' . ($params->{latitude} - 0.01)
. ',' . ($params->{longitude} + 0.01) . ',' . ($params->{latitude} + 0.01);
# Create one open and one fixed report in each category
foreach my $category ( @$categories ) {
+ $mech->create_contact_ok( category => $category, body_id => $body->id, email => "$category\@example.org" );
foreach my $state ( 'confirmed', 'fixed' ) {
my %report_params = (
%$params,
category => $category,
state => $state,
);
- $mech->create_problems_for_body( 1, 2237, 'Around page', \%report_params );
+ $mech->create_problems_for_body( 1, $body->id, 'Around page', \%report_params );
}
}
@@ -163,6 +166,14 @@ subtest 'check category and status filtering works on /around?ajax' => sub {
my $pins = $json->{pins};
is scalar @$pins, 6, 'correct number of reports when no filters';
+ # Regression test for filter_category in /around URL
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $mech->get_ok( '/around?filter_category=Pothole&bbox=' . $bbox );
+ $mech->content_contains('<option value="Pothole" selected>');
+ };
+
$json = $mech->get_ok_json( '/around?ajax=1&filter_category=Pothole&bbox=' . $bbox );
$pins = $json->{pins};
is scalar @$pins, 2, 'correct number of Pothole reports';
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index d6ea9de18..be8500729 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -112,8 +112,9 @@ function isR2L() {
},
make_multi: function() {
- // A convenience wrapper around $.multiSelect() that translates HTML
- // data-* attributes into settings for the multiSelect constructor.
+ // A convenience wrapper around $.multiSelect() that translates HTML
+ // data-* attributes into settings for the multiSelect constructor.
+ return this.each(function() {
var $select = $(this);
var settings = {};
@@ -144,6 +145,7 @@ function isR2L() {
}
$select.multiSelect(settings);
+ });
}
});