diff options
author | Matthew Somerville <matthew@mysociety.org> | 2014-12-10 15:56:02 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2014-12-10 15:56:02 +0000 |
commit | 531c82a90209a5f02d3ab2fc998296e49879ef6f (patch) | |
tree | 594f7b92a9bbb32d2a41a7a4eef0d7b27c29402d /t | |
parent | 0d070cca6c534cec77d04b53a1c21325dbdaecfd (diff) |
Add Open311 i18n test, and add utf8 pragma.
Also remove some unused variables.
Diffstat (limited to 't')
-rw-r--r-- | t/open311.t | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/t/open311.t b/t/open311.t index f23198ea5..0caacbffc 100644 --- a/t/open311.t +++ b/t/open311.t @@ -1,5 +1,6 @@ #!/usr/bin/env perl +use utf8; use strict; use warnings; use Test::More; @@ -77,8 +78,6 @@ subtest 'posting service request' => sub { is $results->{ res }, 248, 'got request id'; - my $req = $o->test_req_used; - my $description = <<EOT; title: a problem @@ -117,8 +116,6 @@ subtest 'posting service request with basic_description' => sub { is $results->{ res }, 248, 'got request id'; - my $req = $o->test_req_used; - my $c = CGI::Simple->new( $results->{ req }->content ); is $c->param('description'), $problem->detail, 'description correct'; @@ -182,7 +179,6 @@ for my $test ( my $results = make_service_req( $problem, $extra, $problem->category, '<?xml version="1.0" encoding="utf-8"?><service_requests><request><service_request_id>248</service_request_id></request></service_requests>' ); - my $req = $o->test_req_used; my $c = CGI::Simple->new( $results->{req}->content ); for my $param ( @{ $test->{params} } ) { @@ -207,7 +203,6 @@ for my $test ( my $results = make_service_req( $problem, $extra, $problem->category, '<?xml version="1.0" encoding="utf-8"?><service_requests><request><service_request_id>248</service_request_id></request></service_requests>' ); - my $req = $o->test_req_used; my $c = CGI::Simple->new( $results->{req}->content ); is $c->param( 'first_name' ), $test->{first_name}, 'correct first name'; @@ -232,8 +227,6 @@ subtest 'basic request update post parameters' => sub { is $results->{ res }, 248, 'got update id'; - my $req = $o->test_req_used; - my $c = CGI::Simple->new( $results->{ req }->content ); is $c->param('description'), 'this is a comment', 'email correct'; @@ -252,8 +245,6 @@ subtest 'extended request update post parameters' => sub { is $results->{ res }, 248, 'got update id'; - my $req = $o->test_req_used; - my $c = CGI::Simple->new( $results->{ req }->content ); is $c->param('description'), 'this is a comment', 'email correct'; @@ -278,8 +269,6 @@ subtest 'check media url set' => sub { is $results->{ res }, 248, 'got update id'; - my $req = $o->test_req_used; - my $c = CGI::Simple->new( $results->{ req }->content ); my $expected_path = '/c/' . $comment->id . '.full.jpeg'; like $c->param('media_url'), qr/$expected_path/, 'image url included'; @@ -664,8 +653,31 @@ for my $test ( }; } +subtest 'check FixaMinGata' => sub { + $problem->cobrand('fixamingata'); + $problem->detail("MØØse"); + my $extra = { + url => 'http://example.com/report/1', + }; + my $results = make_service_req( $problem, $extra, $problem->category, '<?xml version="1.0" encoding="utf-8"?><service_requests><request><service_request_id>248</service_request_id></request></service_requests>' ); + is $results->{ res }, 248, 'got request id'; + my $description = <<EOT; +Beskrivning: MØØse + +Länk till ärendet: http://example.com/report/1 + +Skickad via FixaMinGata +EOT +; + my $c = CGI::Simple->new( $results->{ req }->content ); + (my $c_description = $c->param('description')) =~ s/\r\n/\n/g; + utf8::decode($c_description); + is $c_description, $description, 'description correct'; +}; + done_testing(); + sub make_update_req { my $comment = shift; my $xml = shift; @@ -679,7 +691,7 @@ sub make_update_req { open311_conf => $open311_args, }; - return make_req( $params ); + return _make_req( $params ); } sub make_service_req { @@ -689,7 +701,7 @@ sub make_service_req { my $xml = shift; my $open311_args = shift || {}; - return make_req( + return _make_req( { object => $problem, xml => $xml, @@ -701,7 +713,7 @@ sub make_service_req { ); } -sub make_req { +sub _make_req { my $args = shift; my $object = $args->{object}; |