aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Contact.pm11
-rw-r--r--t/app/controller/contact.t54
-rw-r--r--templates/web/default/contact/index.html4
3 files changed, 55 insertions, 14 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm
index 0e6e60944..558a354c6 100644
--- a/perllib/FixMyStreet/App/Controller/Contact.pm
+++ b/perllib/FixMyStreet/App/Controller/Contact.pm
@@ -76,14 +76,11 @@ sub determine_contact_type : Private {
);
if ($update_id) {
+ my $update = $c->model('DB::Comment')->find(
+ { id => $update_id }
+ );
- # FIXME: updates not implemented yet
-
-# my $u = dbh()->selectrow_hashref(
-# 'select comment.text, comment.name, problem.title, extract(epoch from comment.confirmed) as confirmed
-# from comment, problem where comment.id=?
-# and comment.problem_id = problem.id
-# and comment.problem_id=?', {}, $update_id ,$id);
+ $c->stash->{update} = $update;
}
elsif ($problem) {
$c->stash->{problem} = $problem;
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;
};
}
diff --git a/templates/web/default/contact/index.html b/templates/web/default/contact/index.html
index ff08d10e8..35c7f7e36 100644
--- a/templates/web/default/contact/index.html
+++ b/templates/web/default/contact/index.html
@@ -14,10 +14,8 @@
[% loc('You are reporting the following update for being abusive, containing personal information, or similar:') %]
</p>
- [% IF update.title %]
+ [% IF update.text %]
<blockquote>
- <h2>[% update.title | html %]</h2>
-
<p>
[% IF update.anonymous %]
[% tprintf( loc('Update below added anonymously at %s'), prettify_epoch( update.confirmed_local.epoch ) ) %]