aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/report_display.t
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-05-16 16:11:08 +0100
committerStruan Donald <struan@exo.org.uk>2011-05-16 16:11:08 +0100
commit19bd438d52aa3f0bd707a899025b38eb9d4f27c4 (patch)
tree8890e73bacb63a1d0419dd54a28cb040d5114bd7 /t/app/controller/report_display.t
parent48e1e41ac938333a2f883e03873723e66c55fb40 (diff)
tests for correct problem page meta information
Diffstat (limited to 't/app/controller/report_display.t')
-rw-r--r--t/app/controller/report_display.t81
1 files changed, 81 insertions, 0 deletions
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t
index f0f1bdcba..8a0bfb4c3 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -5,6 +5,7 @@ use Test::More;
use FixMyStreet::TestMech;
use Web::Scraper;
use Path::Class;
+use DateTime;
my $mech = FixMyStreet::TestMech->new;
@@ -15,6 +16,15 @@ my $user =
->find_or_create( { email => 'test@example.com', name => 'Test User' } );
ok $user, "created test user";
+my $dt = DateTime->new(
+ year => 2011,
+ month => 04,
+ day => 16,
+ hour => 15,
+ minute => 47,
+ second => 23
+);
+
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
@@ -27,6 +37,7 @@ my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
name => 'Test User',
anonymous => 'f',
state => 'confirmed',
+ confirmed => $dt->ymd . ' ' . $dt->hms,
lang => 'en-gb',
service => '',
cobrand => 'default',
@@ -90,8 +101,78 @@ subtest "change report to hidden and check for 410 status" => sub {
subtest "test a good report" => sub {
$mech->get_ok("/report/$report_id");
is $mech->uri->path, "/report/$report_id", "at /report/$report_id";
+ is $mech->extract_problem_meta,
+ 'Reported by Test User at 15:47, Saturday 16 April 2011',
+ 'correct problem meta information';
};
+foreach my $meta (
+ {
+ anonymous => 'f',
+ category => 'Other',
+ service => '',
+ meta => 'Reported by Test User at 15:47, Saturday 16 April 2011'
+ },
+ {
+ anonymous => 'f',
+ category => 'Roads',
+ service => '',
+ meta =>
+'Reported in the Roads category by Test User at 15:47, Saturday 16 April 2011'
+ },
+ {
+ anonymous => 'f',
+ category => '',
+ service => 'Transport service',
+ meta =>
+'Reported by Transport service by Test User at 15:47, Saturday 16 April 2011'
+ },
+ {
+ anonymous => 'f',
+ category => 'Roads',
+ service => 'Transport service',
+ meta =>
+'Reported by Transport service in the Roads category by Test User at 15:47, Saturday 16 April 2011'
+ },
+ {
+ anonymous => 't',
+ category => 'Other',
+ service => '',
+ meta => 'Reported anonymously at 15:47, Saturday 16 April 2011'
+ },
+ {
+ anonymous => 'f',
+ category => 'Roads',
+ service => '',
+ meta =>
+'Reported in the Roads category anonymously at 15:47, Saturday 16 April 2011'
+ },
+ {
+ anonymous => 'f',
+ category => '',
+ service => 'Transport service',
+ meta =>
+'Reported by Transport service anonymously at 15:47, Saturday 16 April 2011'
+ },
+ {
+ anonymous => 'f',
+ category => 'Roads',
+ service => 'Transport service',
+ meta =>
+'Reported by Transport service in the Roads category anonymously at 15:47, Saturday 16 April 2011'
+ },
+ )
+{
+ $report->service( $meta->{service} );
+ $report->category( $meta->{category} );
+ $report->anonymous( $meta->{anonymous} );
+ $report->update;
+ subtest "test correct problem meta information" => sub {
+ $mech->get_ok("/report/$report_id");
+
+ };
+}
+
# tidy up
$mech->delete_user('test@example.com');
done_testing();