aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-09-21 11:41:23 +0100
committerStruan Donald <struan@exo.org.uk>2011-09-21 11:41:23 +0100
commitd941a8c26e943c941f8e37ecbd9a9982dd41cb70 (patch)
tree75ea20fb18e984912ba60e4e499114c83cf431fe /t
parent9da2d7b0e806407e3ed5e5418a53fca64757a39a (diff)
parent77f31e8c96c727ea5ab9cf217cfd924074e8f3ed (diff)
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/fixmystreet into js-validation
Conflicts: templates/web/default/report/display.html
Diffstat (limited to 't')
-rw-r--r--t/app/controller/about.t2
-rw-r--r--t/app/controller/alert.t6
-rw-r--r--t/app/controller/open311.t13
-rw-r--r--t/app/controller/questionnaire.t32
-rw-r--r--t/app/controller/report_display.t10
-rw-r--r--t/app/controller/report_new.t17
-rw-r--r--t/app/controller/report_updates.t22
-rw-r--r--t/i18n.t4
8 files changed, 81 insertions, 25 deletions
diff --git a/t/app/controller/about.t b/t/app/controller/about.t
index a5fb215d3..ea7b1af20 100644
--- a/t/app/controller/about.t
+++ b/t/app/controller/about.t
@@ -9,7 +9,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});
-$mech->content_contains('html lang="en-gb"');
+$mech->content_contains('html class="no-js" lang="en-gb"');
SKIP: {
skip( "Need 'emptyhomes' in ALLOWED_COBRANDS config", 8 )
diff --git a/t/app/controller/alert.t b/t/app/controller/alert.t
index b8e38ec92..e1ebbecb6 100644
--- a/t/app/controller/alert.t
+++ b/t/app/controller/alert.t
@@ -12,18 +12,18 @@ ok( my $mech = Test::WWW::Mechanize::Catalyst->new, 'Created mech object' );
$mech->get_ok('/alert');
$mech->title_like(qr/^Local RSS feeds and email alerts/);
$mech->content_contains('Local RSS feeds and email alerts');
-$mech->content_contains('html lang="en-gb"');
+$mech->content_contains('html class="no-js" lang="en-gb"');
# check that we can get list page
$mech->get_ok('/alert/list');
$mech->title_like(qr/^Local RSS feeds and email alerts/);
$mech->content_contains('Local RSS feeds and email alerts');
-$mech->content_contains('html lang="en-gb"');
+$mech->content_contains('html class="no-js" lang="en-gb"');
$mech->get_ok('/alert/list?pc=EH99 1SP');
$mech->title_like(qr/^Local RSS feeds and email alerts/);
$mech->content_contains('Here are the types of local problem alerts for &lsquo;EH99&nbsp;1SP&rsquo;');
-$mech->content_contains('html lang="en-gb"');
+$mech->content_contains('html class="no-js" lang="en-gb"');
$mech->content_contains('Problems within 8.5km');
$mech->content_contains('rss/pc/EH991SP/2');
$mech->content_contains('rss/pc/EH991SP/5');
diff --git a/t/app/controller/open311.t b/t/app/controller/open311.t
new file mode 100644
index 000000000..9b0a6f8af
--- /dev/null
+++ b/t/app/controller/open311.t
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+use FixMyStreet::TestMech;
+my $mech = FixMyStreet::TestMech->new;
+
+# Check old .cgi links redirect correctly
+$mech->get_ok('/open311.cgi/v2/requests.rss?jurisdiction_id=fiksgatami.no&status=open&agency_responsible=1854');
+like $mech->uri, qr[/open311/v2/requests\.rss\?.{65}]; # Don't know order parameters will be in now
+
+done_testing();
diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t
index a013569ee..0e2a71184 100644
--- a/t/app/controller/questionnaire.t
+++ b/t/app/controller/questionnaire.t
@@ -28,7 +28,7 @@ my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
areas => ',11808,135007,14419,134935,2651,20728,',
category => 'Street lighting',
title => 'Testing',
- detail => 'Testing Detail',
+ detail => "Testing \x{2013} Detail",
used_map => 1,
name => $user->name,
anonymous => 0,
@@ -38,7 +38,7 @@ my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
whensent => $sent_time,
lang => 'en-gb',
service => '',
- cobrand => 'default',
+ cobrand => '',
cobrand_data => '',
send_questionnaire => 1,
latitude => '55.951963',
@@ -56,6 +56,10 @@ FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires( {
my $email = $mech->get_email;
ok $email, "got an email";
like $email->body, qr/fill in our short questionnaire/i, "got questionnaire email";
+
+like $email->body, qr/Testing =96 Detail/, 'email contains encoded character';
+is $email->header('Content-Type'), 'text/plain; charset="windows-1252"', 'in the right character set';
+
my ($token) = $email->body =~ m{http://.*?/Q/(\S+)};
ok $token, "extracted questionnaire token '$token'";
$mech->clear_emails_ok;
@@ -330,6 +334,8 @@ FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires( {
} );
$email = $mech->get_email;
ok $email, "got an email";
+$mech->clear_emails_ok;
+
like $email->body, qr/fill in this short questionnaire/i, "got questionnaire email";
($token) = $email->body =~ m{http://.*?/Q/(\S+)};
ok $token, "extracted questionnaire token '$token'";
@@ -346,7 +352,7 @@ my $questionnaire2 = FixMyStreet::App->model('DB::Questionnaire')->find_or_creat
ever_reported => 1,
}
);
-ok $questionnaire, 'added another questionnaire';
+ok $questionnaire2, 'added another questionnaire';
ok $mech->host("fixmystreet.com"), 'change host to fixmystreet';
$mech->get_ok("/Q/" . $token);
$mech->title_like( qr/Questionnaire/ );
@@ -358,5 +364,25 @@ ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes';
$mech->get_ok("/Q/" . $token);
$mech->content_contains( 'made a lot of progress' );
+$token = FixMyStreet::App->model("DB::Token")->find( { scope => 'questionnaire', token => $token } );
+ok $token, 'found token for questionnaire';
+$questionnaire = FixMyStreet::App->model('DB::Questionnaire')->find( { id => $token->data } );
+ok $questionnaire, 'found questionnaire';
+
+# I18N Unicode extra testing using FiksGataMi
+$report->send_questionnaire( 1 );
+$report->cobrand( 'fiksgatami' );
+$report->update;
+$questionnaire->delete;
+$questionnaire2->delete;
+FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires( { site => 'fixmystreet' } ); # It's either fixmystreet or emptyhomes
+$email = $mech->get_email;
+ok $email, "got an email";
+$mech->clear_emails_ok;
+
+like $email->body, qr/Testing =96 Detail/, 'email contains encoded character from user';
+like $email->body, qr/sak p=E5 FiksGataMi/, 'email contains encoded character from template';
+is $email->header('Content-Type'), 'text/plain; charset="windows-1252"', 'email is in right encoding';
+
$mech->delete_user('test@example.com');
done_testing();
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t
index a70d5b9e9..c7455a99b 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -193,8 +193,8 @@ for my $test (
description => 'new report',
date => DateTime->now,
state => 'confirmed',
- banner_id => '',
- banner_text => '',
+ banner_id => undef,
+ banner_text => undef,
fixed => 0
},
{
@@ -293,8 +293,10 @@ for my $test (
$mech->get_ok("/report/$report_id");
is $mech->uri->path, "/report/$report_id", "at /report/$report_id";
my $banner = $mech->extract_problem_banner;
- $banner->{text} =~ s/^ //g;
- $banner->{text} =~ s/ $//g;
+ if ( $banner->{text} ) {
+ $banner->{text} =~ s/^ //g;
+ $banner->{text} =~ s/ $//g;
+ }
is $banner->{id}, $test->{banner_id}, 'banner id';
is $banner->{text}, $test->{banner_text}, 'banner text';
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 807fc6e72..ff4f4294f 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -566,6 +566,7 @@ subtest "test report creation for a user who is signing in as they report" => su
};
#### test report creation for user with account and logged in
+my ($saved_lat, $saved_lon);
foreach my $test (
{ category => 'Trees', council => 2326 },
{ category => 'Potholes', council => 2226 },
@@ -614,7 +615,7 @@ foreach my $test (
$mech->submit_form_ok(
{
with_fields => {
- title => 'Test Report',
+ title => "Test Report at caf\xc3\xa9",
detail => 'Test report details.',
photo => '',
name => 'Joe Bloggs',
@@ -654,12 +655,26 @@ foreach my $test (
# user is still logged in
$mech->logged_in_ok;
+ # Test that AJAX pages return the right data
+ $mech->get_ok(
+ '/ajax?bbox=' . ($report->longitude - 0.01) . ',' . ($report->latitude - 0.01)
+ . ',' . ($report->longitude + 0.01) . ',' . ($report->latitude + 0.01)
+ );
+ $mech->content_contains( "Test Report at caf\xc3\xa9" );
+ $saved_lat = $report->latitude;
+ $saved_lon = $report->longitude;
+
# cleanup
$mech->delete_user($user);
};
}
+$contact2->category( "Pothol\xe9s" );
+$contact2->update;
+$mech->get_ok( '/report/new/ajax?latitude=' . $saved_lat . '&longitude=' . $saved_lon );
+$mech->content_contains( "Pothol\xc3\xa9s" );
+
#### test uploading an image
#### test completing a partial report (eq flickr upload)
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 4469d4003..5719b13e3 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -749,8 +749,8 @@ for my $test (
changed => {
update => 'Update from a registered user'
},
- initial_banner => '',
- endstate_banner => '',
+ initial_banner => undef,
+ endstate_banner => undef,
alert => 0,
anonymous => 0,
},
@@ -775,8 +775,8 @@ for my $test (
changed => {
update => 'Update from a registered user'
},
- initial_banner => '',
- endstate_banner => '',
+ initial_banner => undef,
+ endstate_banner => undef,
alert => 0,
anonymous => 1,
},
@@ -800,8 +800,8 @@ for my $test (
changed => {
update => 'Update from a registered user'
},
- initial_banner => '',
- endstate_banner => '',
+ initial_banner => undef,
+ endstate_banner => undef,
alert => 1,
anonymous => 0,
},
@@ -825,7 +825,7 @@ for my $test (
changed => {
update => 'Update from a registered user'
},
- initial_banner => '',
+ initial_banner => undef,
endstate_banner => ' This problem has been fixed. ',
alert => 1,
anonymous => 0,
@@ -926,7 +926,7 @@ foreach my $test (
fixed => 1,
},
changed => { update => 'Update from owner' },
- initial_banner => '',
+ initial_banner => undef,
initial_state => 'confirmed',
alert => 1, # we signed up for alerts before, do not unsign us
anonymous => 0,
@@ -981,7 +981,7 @@ foreach my $test (
fixed => 1,
},
changed => { update => 'Update from owner' },
- initial_banner => '',
+ initial_banner => undef,
initial_state => 'confirmed',
alert => 1, # we signed up for alerts before, do not unsign us
anonymous => 0,
@@ -1098,7 +1098,7 @@ for my $test (
fixed => 1,
},
changed => { update => 'Update from owner' },
- initial_banner => '',
+ initial_banner => undef,
alert => 1, # we signed up for alerts before, do not unsign us
anonymous => 0,
answered => 0,
@@ -1119,7 +1119,7 @@ for my $test (
fixed => 1,
},
changed => { update => 'Update from owner' },
- initial_banner => '',
+ initial_banner => undef,
alert => 1, # we signed up for alerts before, do not unsign us
anonymous => 0,
answered => 1,
diff --git a/t/i18n.t b/t/i18n.t
index 2279ca6a8..4179dd8d0 100644
--- a/t/i18n.t
+++ b/t/i18n.t
@@ -19,8 +19,8 @@ die "You need to run 'commonlib/bin/gettext-makemo --quiet FixMyStreet' "
'locale/cy_GB.UTF-8/LC_MESSAGES/FixMyStreet-EmptyHomes.mo');
# Example strings
-my $english = "Sorry! Something's gone wrong.";
-my $welsh = "Ymddiheuriadau! Mae rhywbeth wedi mynd o'i le.";
+my $english = "Please enter a valid email";
+my $welsh = "Cofnodwch gyfeiriad e-bost dilys";
# set english as the language
mySociety::Locale::negotiate_language( #