aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/open311.t13
-rw-r--r--t/app/controller/questionnaire.t32
-rw-r--r--t/app/controller/report_new.t17
3 files changed, 58 insertions, 4 deletions
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_new.t b/t/app/controller/report_new.t
index fa188210a..9158231df 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -516,6 +516,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 },
@@ -564,7 +565,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',
@@ -604,12 +605,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)