aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/report_updates.t
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller/report_updates.t')
-rw-r--r--t/app/controller/report_updates.t25
1 files changed, 21 insertions, 4 deletions
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 0b6d4ae3e..84f52eaa5 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -146,14 +146,22 @@ subtest "unconfirmed updates not displayed" => sub {
};
subtest "several updates shown in correct order" => sub {
- for my $fields ( {
+ my @qs;
+ for my $fields ( { # One with an associated update below
problem_id => $report_id,
whensent => '2011-03-10 12:23:16',
whenanswered => '2011-03-10 12:23:16',
old_state => 'confirmed',
new_state => 'confirmed',
},
- {
+ { # One with no associated update
+ problem_id => $report_id,
+ whensent => '2011-03-11 12:23:16',
+ whenanswered => '2011-03-11 12:23:16',
+ old_state => 'confirmed',
+ new_state => 'confirmed',
+ },
+ { # One for the fixed update
problem_id => $report_id,
whensent => '2011-03-15 08:12:36',
whenanswered => '2011-03-15 08:12:36',
@@ -164,6 +172,7 @@ subtest "several updates shown in correct order" => sub {
my $q = FixMyStreet::App->model('DB::Questionnaire')->find_or_create(
$fields
);
+ push @qs, $q;
}
for my $fields ( {
@@ -200,6 +209,14 @@ subtest "several updates shown in correct order" => sub {
my $comment = FixMyStreet::App->model('DB::Comment')->find_or_create(
$fields
);
+ if ($fields->{text} eq 'Second update') {
+ $comment->set_extra_metadata(questionnaire_id => $qs[0]->id);
+ $comment->update;
+ }
+ if ($fields->{text} eq 'Third update') {
+ $comment->set_extra_metadata(questionnaire_id => $qs[2]->id);
+ $comment->update;
+ }
}
$mech->get_ok("/report/$report_id");
@@ -207,8 +224,8 @@ subtest "several updates shown in correct order" => sub {
my $meta = $mech->extract_update_metas;
is scalar @$meta, 5, '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', 'second update';
- is $meta->[2], 'Still open, via questionnaire, 12:23, Thu 10 March 2011', 'questionnaire';
+ 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';
$report->questionnaires->delete;