aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2020-08-25 17:04:01 +0100
committerDave Arter <davea@mysociety.org>2020-08-28 12:33:13 +0100
commitf784713cbebb8e9026544ab969a5a3404f736429 (patch)
tree1f6f94108e0821d036ff5d3ff4166c644c613ef1 /t/app/controller
parent470c24e00b12ac82fa7d34534cb9c1bd6cda53ff (diff)
Don’t display duplicate categories in filter on /around and /my
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/around.t31
1 files changed, 31 insertions, 0 deletions
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index 29752ab02..3f5d31c02 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -309,6 +309,37 @@ subtest 'check category, status and extra filtering works on /around' => sub {
is scalar @$pins, 1, 'correct number of external_body reports';
};
+subtest 'check categories with same name are only shown once in filters' => sub {
+ my $params = {
+ 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);
+
+ my $district = $mech->create_body_ok(2421, "Oxford City");
+ # Identically-named categories should be combined even if their extra metadata is different
+ my $contact2 = $mech->create_contact_ok( category => "Pothole", body_id => $district->id, email => 'pothole@district-example.org' );
+ $contact2->set_extra_metadata(some_extra_field => "dummy");
+ $contact2->update;
+ # And categories with the same display name should be combined too
+ my $contact3 = $mech->create_contact_ok( category => "Pothole (alternative)", body_id => $district->id, email => 'pothole-alternative@district-example.org' );
+ $contact3->set_extra_metadata(display_name => "Pothole");
+ $contact3->update;
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'fixmystreet',
+ MAPIT_URL => 'http://mapit.uk/',
+ COBRAND_FEATURES => { category_groups => { fixmystreet => 1 } },
+ }, sub {
+ $mech->get_ok( '/around?bbox=' . $bbox );
+ $mech->content_contains('<option value="Pothole">');
+ $mech->content_unlike(qr{Pothole</option>.*<option value="Pothole">\s*Pothole</option>}s, "Pothole category only appears once");
+ $mech->content_lacks('<option value="Pothole (alternative)">');
+ };
+};
+
subtest 'check old problems not shown by default on around page' => sub {
my $params = {
postcode => 'OX20 1SZ',