aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-05-26 13:12:47 +0100
committerStruan Donald <struan@exo.org.uk>2011-05-26 13:12:47 +0100
commit0030a9d9760c1f8733fb5b64486aaa634d1023bb (patch)
tree2e60cfda4204f7cef933116a9a8fc41068135581 /t/app
parent21d9bb9813ace93504a6a2b8a4d134c4edb5dbee (diff)
update reporting
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/contact.t54
1 files changed, 50 insertions, 4 deletions
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t
index fbf794b6b..73660306d 100644
--- a/t/app/controller/contact.t
+++ b/t/app/controller/contact.t
@@ -31,6 +31,21 @@ for my $test (
anonymous => 1,
meta => 'Reported anonymously at 13:24, Tuesday 3 May 2011',
},
+ {
+ name => 'A User',
+ email => 'problem_report_test@example.com',
+ title => 'A different problem',
+ detail => 'More detail on the different problem',
+ postcode => 'EH99 1SP',
+ confirmed => '2011-05-03 13:24:28.145168',
+ anonymous => 1,
+ meta => 'Reported anonymously at 13:24, Tuesday 3 May 2011',
+ update => {
+ name => 'Different User',
+ email => 'commenter@example.com',
+ text => 'This is an update',
+ },
+ },
)
{
subtest 'check reporting a problem displays correctly' => sub {
@@ -58,13 +73,44 @@ for my $test (
}
);
+ my $update;
+
+ if ( $test->{update} ) {
+ my $update_info = $test->{update};
+ my $update_user = FixMyStreet::App->model('DB::User')->find_or_create(
+ {
+ name => $update_info->{name},
+ email => $update_info->{email}
+ }
+ );
+
+ $update = FixMyStreet::App->model('DB::Comment')->create(
+ {
+ problem_id => $problem->id,
+ user => $update_user,
+ state => 'confirmed',
+ text => $update_info->{text},
+ confirmed => \'ms_current_timestamp()',
+ mark_fixed => 'f',
+ anonymous => 'f',
+ }
+ );
+ }
+
ok $problem, 'succesfully create a problem';
- $mech->get_ok( '/contact?id=' . $problem->id );
- $mech->content_contains('reporting the following problem');
- $mech->content_contains( $test->{title} );
- $mech->content_contains( $test->{meta} );
+ if ( $update ) {
+ $mech->get_ok( '/contact?id=' . $problem->id . '&update_id=' . $update->id );
+ $mech->content_contains('reporting the following update');
+ $mech->content_contains( $test->{update}->{text} );
+ } else {
+ $mech->get_ok( '/contact?id=' . $problem->id );
+ $mech->content_contains('reporting the following problem');
+ $mech->content_contains( $test->{title} );
+ $mech->content_contains( $test->{meta} );
+ }
+ $update->delete if $update;
$problem->delete;
};
}