diff options
Diffstat (limited to 't/app/controller/area_stats.t')
-rw-r--r-- | t/app/controller/area_stats.t | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/t/app/controller/area_stats.t b/t/app/controller/area_stats.t index 6ea03cabf..ce2e3d7d6 100644 --- a/t/app/controller/area_stats.t +++ b/t/app/controller/area_stats.t @@ -98,6 +98,8 @@ FixMyStreet::override_config { $mech->text_contains('Potholes6'); $mech->text_contains('Traffic lights13'); + + $mech->text_contains('average time between issue being opened and set to another status was 0 days'); }; subtest 'shows correct stats to area user' => sub { @@ -183,6 +185,17 @@ FixMyStreet::override_config { $mech->text_contains('Traffic lights3730'); }; + subtest 'ignores second state change if first was last month' => sub { + my $comment = $scheduled_problems[0]->comments->search({}, { order_by => { '-asc' => 'id' } } )->first; + $comment->update({ confirmed => DateTime->now->subtract(days => 40) }); + $mech->get_ok("/admin/areastats/$body_id?area=20720"); + + $mech->content_contains('15 opened, 6 scheduled, 3 closed, 4 fixed'); + $mech->text_contains('Potholes2004'); + $mech->text_contains('Traffic lights3730'); + $comment->update({ confirmed => DateTime->now }); + }; + subtest 'average is only to first state change' => sub { for my $i (0..4) { $scheduled_problems[$i]->comments->first->update({ confirmed => $scheduled_problems[$i]->confirmed }); @@ -201,6 +214,16 @@ FixMyStreet::override_config { $mech->get_ok("/admin/areastats/$body_id?area=20720"); $mech->text_contains('average time between issue being opened and set to another status was 4 days'); }; + + subtest 'shows no problems changed state if no average' => sub { + for my $p (@scheduled_problems, @fixed_problems, @closed_problems) { + $p->comments->delete; + } + + $mech->get_ok("/admin/areastats/$body_id?area=20720"); + $mech->text_contains('17 opened, 0 scheduled, 0 closed, 0 fixed'); + $mech->text_contains('no problems changed state'); + } }; END { |