aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-05-13 13:12:08 +0100
committerStruan Donald <struan@exo.org.uk>2011-05-13 13:12:08 +0100
commit84053fd846af39f03c8e6087e9f1df41dffe62ff (patch)
tree076e5567c7c1a7e54d4670f4c56203927bcc1c23
parent97e3eba9fb3a3dac185f62c7d6c7a16d1438c34f (diff)
tests/fixes for anonymous reports
-rw-r--r--t/app/controller/contact.t94
-rw-r--r--templates/web/default/contact/index.html6
2 files changed, 61 insertions, 39 deletions
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t
index 9d232c8ff..412b834f3 100644
--- a/t/app/controller/contact.t
+++ b/t/app/controller/contact.t
@@ -10,41 +10,63 @@ $mech->get_ok('/contact');
$mech->title_like(qr/Contact Us/);
$mech->content_contains("We'd love to hear what you think about this site");
-subtest 'check reporting a problem displays correctly' => sub {
- my $user = FixMyStreet::App->model('DB::User')->find_or_create(
- {
- name => 'A User',
- email => 'problem_report_rest@example.com'
- }
- );
-
- my $problem = FixMyStreet::App->model('DB::Problem')->create(
- {
- title => 'Some problem or other',
- detail => 'More detail on the problem',
- postcode => 'EH99 1SP',
- confirmed => '2011-05-04 10:44:28.145168',
- latitude => 0,
- longitude => 0,
- areas => 0,
- used_map => 0,
- name => 'Problem User',
- anonymous => 0,
- state => 'confirmed',
- user => $user
- }
- );
-
- ok $problem, 'succesfully create a problem';
-
- $mech->get_ok( '/contact?id=' . $problem->id );
- $mech->content_contains('reporting the following problem');
- $mech->content_contains('Some problem or other');
- $mech->content_contains('Reported by A User');
- $mech->content_contains(
- 'Reported by A User at 10:44, Wednesday 4 May 2011');
-
- $problem->delete;
-};
+for my $test (
+ {
+ name => 'A User',
+ email => 'problem_report_test@example.com',
+ title => 'Some problem or other',
+ detail => 'More detail on the problem',
+ postcode => 'EH99 1SP',
+ confirmed => '2011-05-04 10:44:28.145168',
+ anonymous => 0,
+ meta => 'Reported by A User at 10:44, Wednesday 4 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',
+ },
+ )
+{
+ subtest 'check reporting a problem displays correctly' => sub {
+ my $user = FixMyStreet::App->model('DB::User')->find_or_create(
+ {
+ name => $test->{name},
+ email => $test->{email}
+ }
+ );
+
+ my $problem = FixMyStreet::App->model('DB::Problem')->create(
+ {
+ title => $test->{title},
+ detail => $test->{detail},
+ postcode => $test->{postcode},
+ confirmed => $test->{confirmed},
+ name => $test->{name},
+ anonymous => $test->{anonymous},
+ state => 'confirmed',
+ user => $user,
+ latitude => 0,
+ longitude => 0,
+ areas => 0,
+ used_map => 0,
+ }
+ );
+
+ 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} );
+
+ $problem->delete;
+ };
+}
done_testing();
diff --git a/templates/web/default/contact/index.html b/templates/web/default/contact/index.html
index dc5c43fdf..b06154083 100644
--- a/templates/web/default/contact/index.html
+++ b/templates/web/default/contact/index.html
@@ -20,14 +20,14 @@
<p>
[% IF update.anonymous %]
- [% tprintf( loc('Update below added anonymously at %s'), update.confirmed ) %]
+ [% tprintf( loc('Update below added anonymously at %s'), prettify_epoch( update.confirmed ) ) %]
[% ELSE %]
[% tprintf( loc('Update below added by %s at %s'), update.name, prettify_epoch( update.confirmed ) ) | html %]
[% END %]
</p>
<p>
- [% update.detail | html %]
+ [% update.text | html %]
</p>
</blockquote>
@@ -44,7 +44,7 @@
<p>
[% IF problem.anonymous %]
- [% tprintf( loc('Reported anonymously at %s'), problem.confirmed ) %]
+ [% tprintf( loc('Reported anonymously at %s'), prettify_epoch( problem.confirmed ) ) %]
[% ELSE %]
[% tprintf( loc('Reported by %s at %s'), problem.user.name, prettify_epoch( problem.confirmed ) ) | html %]
[% END %]