diff options
author | Dave Arter <davea@mysociety.org> | 2015-06-30 11:03:20 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2015-06-30 11:03:20 +0100 |
commit | bff57817b0a8d9d2ab8ceeecbcba17f259d4ac1a (patch) | |
tree | a2a755e57e92c3991c3681ae13d74347ddf0fb9c /t/app/controller | |
parent | 1df64a30dd0939d8d9b8b1854f7f7e421d9b20ab (diff) | |
parent | b2c41d9b9ac0444565cdc8b6dbbaeedf759185ba (diff) |
Merge branch 'report-filtering-on-map'
This branch allows the map pages to be filtered by report category and
status with the 'filter_category' and 'status' GET parameters.
Diffstat (limited to 't/app/controller')
-rw-r--r-- | t/app/controller/around.t | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/t/app/controller/around.t b/t/app/controller/around.t index df4f18660..03bcebf96 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -127,4 +127,43 @@ subtest 'check non public reports are not displayed on around page' => sub { }; +subtest 'check category and status filtering works on /ajax' => sub { + my $categories = [ 'Pothole', 'Vegetation', 'Flytipping' ]; + my $params = { + postcode => 'OX1 1ND', + latitude => 51.7435918829363, + longitude => -1.23201966270446, + }; + 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 ) { + foreach my $state ( 'confirmed', 'fixed' ) { + my %report_params = ( + %$params, + category => $category, + state => $state, + ); + $mech->create_problems_for_body( 1, 2237, 'Around page', \%report_params ); + } + } + + my $json = $mech->get_ok_json( '/ajax?bbox=' . $bbox ); + my $pins = $json->{pins}; + is scalar @$pins, 6, 'correct number of reports when no filters'; + + $json = $mech->get_ok_json( '/ajax?filter_category=Pothole&bbox=' . $bbox ); + $pins = $json->{pins}; + is scalar @$pins, 2, 'correct number of Pothole reports'; + + $json = $mech->get_ok_json( '/ajax?status=open&bbox=' . $bbox ); + $pins = $json->{pins}; + is scalar @$pins, 3, 'correct number of open reports'; + + $json = $mech->get_ok_json( '/ajax?status=fixed&filter_category=Vegetation&bbox=' . $bbox ); + $pins = $json->{pins}; + is scalar @$pins, 1, 'correct number of fixed Vegetation reports'; +}; + done_testing(); |