aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/about.t2
-rw-r--r--t/app/controller/alert.t2
-rw-r--r--t/app/controller/contact.t34
-rw-r--r--t/app/controller/json.t30
4 files changed, 47 insertions, 21 deletions
diff --git a/t/app/controller/about.t b/t/app/controller/about.t
index e1a1641fd..84eab005a 100644
--- a/t/app/controller/about.t
+++ b/t/app/controller/about.t
@@ -8,7 +8,7 @@ ok( my $mech = Test::WWW::Mechanize::Catalyst->new, 'Created mech object' );
# check that we can get the page
$mech->get_ok('/about');
-$mech->content_like(qr{About Us ::\s+FixMyStreet.com});
+$mech->content_like(qr{About us ::\s+FixMyStreet.com});
$mech->content_contains('html lang="en-gb"');
SKIP: {
diff --git a/t/app/controller/alert.t b/t/app/controller/alert.t
index f32d0d6e9..45257b31b 100644
--- a/t/app/controller/alert.t
+++ b/t/app/controller/alert.t
@@ -22,7 +22,7 @@ $mech->content_contains('html lang="en-gb"');
$mech->get_ok('/alert/list?pc=EH99 1SP');
$mech->title_like(qr/^Local RSS feeds and email alerts/);
-$mech->content_contains('Local RSS feeds and email alerts for EH99 1SP');
+$mech->content_contains('Local RSS feeds and email alerts for ‘EH99 1SP’');
$mech->content_contains('html lang="en-gb"');
$mech->content_contains('Problems within 8.5km');
$mech->content_contains('rss/pc/EH991SP/2');
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t
index 73660306d..9808ef762 100644
--- a/t/app/controller/contact.t
+++ b/t/app/controller/contact.t
@@ -10,6 +10,8 @@ $mech->get_ok('/contact');
$mech->title_like(qr/Contact Us/);
$mech->content_contains("We'd love to hear what you think about this site");
+my $problem_main;
+
for my $test (
{
name => 'A User',
@@ -20,6 +22,7 @@ for my $test (
confirmed => '2011-05-04 10:44:28.145168',
anonymous => 0,
meta => 'Reported by A User at 10:44, Wednesday 4 May 2011',
+ main => 1,
},
{
name => 'A User',
@@ -111,7 +114,11 @@ for my $test (
}
$update->delete if $update;
- $problem->delete;
+ if ($test->{main}) {
+ $problem_main = $problem;
+ } else {
+ $problem->delete;
+ }
};
}
@@ -193,7 +200,7 @@ for my $test (
field_errors => [ 'Please write a message', ]
},
{
- url => '/contact?id=1',
+ url => '/contact?id=' . $problem_main->id,
fields => {
em => 'test@example.com',
name => 'A name',
@@ -228,12 +235,25 @@ for my $test (
message => 'A message',
},
},
+ {
+ fields => {
+ em => 'test@example.com',
+ name => 'A name',
+ subject => 'A subject',
+ message => 'A message',
+ id => $problem_main->id,
+ },
+ },
)
{
subtest 'check email sent correctly' => sub {
$mech->clear_emails_ok;
- $mech->get_ok('/contact');
+ if ($test->{fields}{id}) {
+ $mech->get_ok('/contact?id=' . $test->{fields}{id});
+ } else {
+ $mech->get_ok('/contact');
+ }
$mech->submit_form_ok( { with_fields => $test->{fields} } );
$mech->content_contains('Thanks for your feedback');
$mech->email_count_is(1);
@@ -243,7 +263,13 @@ for my $test (
is $email->header('Subject'), 'FMS message: ' . $test->{fields}->{subject}, 'subject';
is $email->header('From'), "\"$test->{fields}->{name}\" <$test->{fields}->{em}>", 'from';
like $email->body, qr/$test->{fields}->{message}/, 'body';
- like $email->body, qr/Sent by contact.cgi on \S+. IP address (?:\d{1,3}\.){3,}\d{1,3}/, 'body footer'
+ like $email->body, qr/Sent by contact.cgi on \S+. IP address (?:\d{1,3}\.){3,}\d{1,3}/, 'body footer';
+ my $problem_id = $test->{fields}{id};
+ like $email->body, qr/Complaint about report $problem_id/, 'reporting a report'
+ if $test->{fields}{id};
};
}
+
+$problem_main->delete;
+
done_testing();
diff --git a/t/app/controller/json.t b/t/app/controller/json.t
index 2c9ff4a61..7c5dce786 100644
--- a/t/app/controller/json.t
+++ b/t/app/controller/json.t
@@ -13,23 +13,23 @@ subtest "check that a bad request produces the appropriate response" => sub {
my $bad_type = "Invalid type supplied";
my %tests = (
- '' => $bad_date,
- 'foo=bar' => $bad_date,
- 'type=&start_date=&end_date=' => $bad_date,
- 'type=&start_date=bad&end_date=2000-02-01' => $bad_date,
- 'type=&start_date=2000-01-01&end_date=bad' => $bad_date,
- 'type=&start_date=2000-02-31&end_date=2000-02-01' => $bad_date,
- 'type=&start_date=2000-01-01&end_date=2000-02-31' => $bad_date,
-
- 'type=&start_date=2000-02-01&end_date=2000-01-01' => $mad_date,
-
- 'type=&start_date=2000-01-01&end_date=2000-02-01' => $bad_type,
- 'type=foo&start_date=2000-01-01&end_date=2000-02-01' => $bad_type,
+ '?' => $bad_date,
+ '?foo=bar' => $bad_date,
+ '?start_date=&end_date=' => $bad_date,
+ '?start_date=bad&end_date=2000-02-01' => $bad_date,
+ '?start_date=2000-01-01&end_date=bad' => $bad_date,
+ '?start_date=2000-02-31&end_date=2000-02-01' => $bad_date,
+ '?start_date=2000-01-01&end_date=2000-02-31' => $bad_date,
+
+ '?start_date=2000-02-01&end_date=2000-01-01' => $mad_date,
+
+ '?start_date=2000-01-01&end_date=2000-02-01' => $bad_type,
+ '/foo?type=foo&start_date=2000-01-01&end_date=2000-02-01' => $bad_type,
);
foreach my $q ( sort keys %tests ) {
is_deeply #
- $mech->get_ok_json("/json?$q"), #
+ $mech->get_ok_json("/json/problems$q"), #
{ error => $tests{$q} }, #
"correct error for query '$q'";
}
@@ -38,7 +38,7 @@ subtest "check that a bad request produces the appropriate response" => sub {
is_deeply #
$mech->get_ok_json(
- "/json?type=new_problems&start_date=2000-01-01&end_date=2000-02-01"), #
+ "/json/problems/new?start_date=2000-01-01&end_date=2000-02-01"), #
[], #
"correct response";
@@ -75,7 +75,7 @@ ok $anon_problem, "created anon test problem";
is_deeply #
$mech->get_ok_json(
- "/json?type=new_problems&start_date=2000-01-01&end_date=2000-02-01"), #
+ "/json/problems/new?start_date=2000-01-01&end_date=2000-02-01"), #
[
{
'anonymous' => 0,