aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand
diff options
context:
space:
mode:
Diffstat (limited to 't/cobrand')
-rw-r--r--t/cobrand/oxfordshire.t50
1 files changed, 50 insertions, 0 deletions
diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t
new file mode 100644
index 000000000..d9f880d07
--- /dev/null
+++ b/t/cobrand/oxfordshire.t
@@ -0,0 +1,50 @@
+use strict;
+use warnings;
+use Test::More;
+
+use FixMyStreet::TestMech;
+my $mech = FixMyStreet::TestMech->new;
+
+subtest 'check /ajax defaults to open reports only' => sub {
+ my $categories = [ 'Bridges', 'Fences', 'Manhole' ];
+ my $params = {
+ postcode => 'OX28 4DS',
+ latitude => 51.7847208192,
+ longitude => -1.49445264029,
+ };
+ 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 );
+ }
+ }
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { 'oxfordshire' => '.' } ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ my $json = $mech->get_ok_json( '/ajax?status=all&bbox=' . $bbox );
+ my $pins = $json->{pins};
+ is scalar @$pins, 6, 'correct number of reports created';
+
+ $json = $mech->get_ok_json( '/ajax?bbox=' . $bbox );
+ $pins = $json->{pins};
+ is scalar @$pins, 3, 'correct number of reports returned with no filters';
+
+ $json = $mech->get_ok_json( '/ajax?filter_category=Fences&bbox=' . $bbox );
+ $pins = $json->{pins};
+ is scalar @$pins, 1, 'only one Fences report by default';
+ }
+};
+
+# Clean up
+$mech->delete_problems_for_body( 2237 );
+done_testing();