aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-07-03 15:56:14 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-07-03 15:56:14 +0100
commit4b20c003ed43ef329c5c126a767f5626f3489d79 (patch)
tree6f927aa25f4040b75a4fb8c6257a0fca75db40ba /t/app/controller
parent7d6d6fd9ae50eeb7b96743d59e8e8d7b36c5a21a (diff)
parent1b7418e2aec2ce269fde49efcff8493e4e24ad7e (diff)
Merge branch 'issues/2098-repaginating-splines'
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/around.t74
1 files changed, 72 insertions, 2 deletions
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index 02abefe7e..dc755a67f 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -137,9 +137,9 @@ subtest 'check non public reports are not displayed on around page' => sub {
};
-subtest 'check category, status and extra filtering works on /around' => sub {
- my $body = $mech->create_body_ok(2237, "Oxfordshire");
+my $body = $mech->create_body_ok(2237, "Oxfordshire");
+subtest 'check category, status and extra filtering works on /around' => sub {
my $categories = [ 'Pothole', 'Vegetation', 'Flytipping' ];
my $params = {
postcode => 'OX20 1SZ',
@@ -195,6 +195,76 @@ subtest 'check category, status and extra filtering works on /around' => sub {
is scalar @$pins, 1, 'correct number of external_body reports';
};
+subtest 'check old problems not shown by default on around page' => 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 $json = $mech->get_ok_json( '/around?ajax=1&bbox=' . $bbox );
+ my $pins = $json->{pins};
+ is scalar @$pins, 9, 'correct number of reports when no age';
+
+ my $problems = FixMyStreet::App->model('DB::Problem')->to_body( $body->id );
+ $problems->first->update( { confirmed => \"current_timestamp-'7 months'::interval" } );
+
+ $json = $mech->get_ok_json( '/around?ajax=1&bbox=' . $bbox );
+ $pins = $json->{pins};
+ is scalar @$pins, 8, 'correct number of reports with old report';
+
+ $json = $mech->get_ok_json( '/around?show_old_reports=1&ajax=1&bbox=' . $bbox );
+ $pins = $json->{pins};
+ is scalar @$pins, 9, 'correct number of reports with show_old_reports';
+
+ $problems->update( { confirmed => \"current_timestamp" } );
+};
+
+subtest 'check sorting by update uses lastupdate to determine age' => 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 $problems = FixMyStreet::App->model('DB::Problem')->to_body( $body->id );
+ $problems->first->update( { confirmed => \"current_timestamp-'7 months'::interval" } );
+
+ my $json = $mech->get_ok_json( '/around?ajax=1&bbox=' . $bbox );
+ my $pins = $json->{pins};
+ is scalar @$pins, 8, 'correct number of reports with default sorting';
+
+
+ $json = $mech->get_ok_json( '/around?ajax=1&sort=updated-desc&bbox=' . $bbox );
+ $pins = $json->{pins};
+ is scalar @$pins, 9, 'correct number of reports with updated sort';
+
+ $problems->update( { confirmed => \"current_timestamp" } );
+};
+
+subtest 'check show old reports checkbox shown on around page' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $mech->get_ok( '/around?pc=OX20+1SZ' );
+ $mech->content_contains('id="show_old_reports_wrapper" class="report-list-filters hidden"');
+
+ my $problems = FixMyStreet::App->model('DB::Problem')->to_body( $body->id );
+ $problems->first->update( { confirmed => \"current_timestamp-'7 months'::interval" } );
+
+ $mech->get_ok( '/around?pc=OX20+1SZ' );
+ $mech->content_lacks('id="show_old_reports_wrapper" class="report-list-filters hidden"');
+ $mech->content_contains('id="show_old_reports_wrapper" class="report-list-filters"');
+
+ $problems->update( { confirmed => \"current_timestamp" } );
+ };
+};
+
subtest 'check skip_around skips around page' => sub {
my $cobrand = Test::MockModule->new('FixMyStreet::Cobrand::Default');
$cobrand->mock('skip_around_page', sub { 1 });