aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm5
-rw-r--r--t/app/controller/report_updates.t16
2 files changed, 16 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 2861f368a..8708c6128 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -163,7 +163,10 @@ sub load_updates : Private {
{
problem_id => $c->stash->{problem}->id,
whenanswered => { '!=', undef },
- old_state => 'confirmed', new_state => 'confirmed',
+ old_state => [ -and =>
+ { -in => [ FixMyStreet::DB::Result::Problem::closed_states, FixMyStreet::DB::Result::Problem::open_states ] },
+ \'= new_state',
+ ]
},
{ order_by => 'whenanswered' }
);
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 84f52eaa5..aba7340b0 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -161,6 +161,13 @@ subtest "several updates shown in correct order" => sub {
old_state => 'confirmed',
new_state => 'confirmed',
},
+ { # One with no associated update, different state (doesn't match problem state, never mind)
+ problem_id => $report_id,
+ whensent => '2011-03-12 12:23:16',
+ whenanswered => '2011-03-12 12:23:16',
+ old_state => 'investigating',
+ new_state => 'investigating',
+ },
{ # One for the fixed update
problem_id => $report_id,
whensent => '2011-03-15 08:12:36',
@@ -214,7 +221,7 @@ subtest "several updates shown in correct order" => sub {
$comment->update;
}
if ($fields->{text} eq 'Third update') {
- $comment->set_extra_metadata(questionnaire_id => $qs[2]->id);
+ $comment->set_extra_metadata(questionnaire_id => $qs[3]->id);
$comment->update;
}
}
@@ -222,12 +229,13 @@ subtest "several updates shown in correct order" => sub {
$mech->get_ok("/report/$report_id");
my $meta = $mech->extract_update_metas;
- is scalar @$meta, 5, 'number of updates';
+ is scalar @$meta, 6, 'number of updates';
is $meta->[0], 'Posted by Other User at 12:23, Thu 10 March 2011', 'first update';
is $meta->[1], 'Posted by Main User at 12:23, Thu 10 March 2011 Still open, via questionnaire', 'second update';
is $meta->[2], 'Still open, via questionnaire, 12:23, Fri 11 March 2011', 'questionnaire';
- is $meta->[3], 'State changed to: Fixed', 'third update, part 1';
- is $meta->[4], 'Posted anonymously at 08:12, Tue 15 March 2011', 'third update, part 2';
+ is $meta->[3], 'Still open, via questionnaire, 12:23, Sat 12 March 2011', 'questionnaire';
+ is $meta->[4], 'State changed to: Fixed', 'third update, part 1';
+ is $meta->[5], 'Posted anonymously at 08:12, Tue 15 March 2011', 'third update, part 2';
$report->questionnaires->delete;
};