aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2019-10-14 12:46:26 +0100
committerDave Arter <davea@mysociety.org>2019-12-09 12:48:12 +0000
commitcbc9a483845567ed0b62709e1ff8b2206acd16ae (patch)
treed66c9502ec23a3be9043cc7c070f0fab9b4cbb2f
parent360791e0f22abd4370e9c0d0c2592643504dafa0 (diff)
[TfL] Apply pin colours & 6 weeks default age on map
Connects https://github.com/mysociety/fixmystreet-commercial/issues/1628
-rw-r--r--perllib/FixMyStreet/Cobrand/TfL.pm10
-rw-r--r--t/cobrand/tfl.t45
2 files changed, 55 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm
index 47fe5a1cf..d6399b5e6 100644
--- a/perllib/FixMyStreet/Cobrand/TfL.pm
+++ b/perllib/FixMyStreet/Cobrand/TfL.pm
@@ -77,4 +77,14 @@ sub lookup_by_ref {
sub report_sent_confirmation_email { 'id' }
+sub report_age { '6 weeks' }
+
+sub pin_colour {
+ my ( $self, $p, $context ) = @_;
+ return 'green' if $p->is_closed;
+ return 'green' if $p->is_fixed;
+ return 'red' if $p->state eq 'confirmed';
+ return 'orange'; # all the other `open_states` like "in progress"
+}
+
1;
diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t
index 769aeec9b..22727387d 100644
--- a/t/cobrand/tfl.t
+++ b/t/cobrand/tfl.t
@@ -107,6 +107,51 @@ subtest 'check lookup by reference' => sub {
is $mech->uri->path, "/report/$id", "redirected to report page when using non-prefixed ref";
};
+for my $test (
+ {
+ states => [ 'confirmed' ],
+ colour => 'red'
+ },
+ {
+ states => ['action scheduled', 'in progress', 'investigating', 'planned'],
+ colour => 'orange'
+ },
+ {
+ states => [ FixMyStreet::DB::Result::Problem->fixed_states, FixMyStreet::DB::Result::Problem->closed_states ],
+ colour => 'green'
+ },
+) {
+ subtest 'check ' . $test->{colour} . ' pin states' => sub {
+ my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'});
+ my $url = '/around?ajax=1&bbox=' . ($report->longitude - 0.01) . ',' . ($report->latitude - 0.01)
+ . ',' . ($report->longitude + 0.01) . ',' . ($report->latitude + 0.01);
+
+ for my $state ( @{ $test->{states} } ) {
+ $report->update({ state => $state });
+ my $json = $mech->get_ok_json( $url );
+ my $colour = $json->{pins}[0][2];
+ is $colour, $test->{colour}, 'correct ' . $test->{colour} . ' pin for state ' . $state;
+ }
+ };
+}
+
+subtest 'check report age on /around' => sub {
+ my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'});
+ $report->update({ state => 'confirmed' });
+
+ $mech->get_ok( '/around?lat=' . $report->latitude . '&lon=' . $report->longitude );
+ $mech->content_contains($report->title);
+
+ $report->update({
+ confirmed => \"current_timestamp-'7 weeks'::interval",
+ whensent => \"current_timestamp-'7 weeks'::interval",
+ lastupdate => \"current_timestamp-'7 weeks'::interval",
+ });
+
+ $mech->get_ok( '/around?lat=' . $report->latitude . '&lon=' . $report->longitude );
+ $mech->content_lacks($report->title);
+};
+
};
done_testing();