aboutsummaryrefslogtreecommitdiffstats
path: root/t/open311.t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-04-08 21:11:48 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-04-08 22:05:21 +0100
commitb7099e8e513fe64ec183b1403515f46a7cc25f19 (patch)
tree8a0399a49f90acfe5b74cf19d86585cc050455d7 /t/open311.t
parent0802b7f04091c1022dce0d77cc806a46ecc4ebba (diff)
Add PNG image support.
Store image type along with hash in photo column, and use that when outputting images / generating URLs. Make sure all public photo URL generation goes through appropriate functions, and change temp URLs so the filename can be output directly from the list.
Diffstat (limited to 't/open311.t')
-rw-r--r--t/open311.t26
1 files changed, 19 insertions, 7 deletions
diff --git a/t/open311.t b/t/open311.t
index 6333355e8..42d09b29c 100644
--- a/t/open311.t
+++ b/t/open311.t
@@ -3,6 +3,8 @@
use utf8;
use strict;
use warnings;
+use File::Temp 'tempdir';
+use Path::Tiny;
use Test::More;
use Test::Warn;
use FixMyStreet::DB;
@@ -24,7 +26,7 @@ EOT
is $o->_process_error( $err_text ), "400: Service Code cannot be null -- can't proceed with the request.\n", 'error text parsing';
is $o->_process_error( '503 - service unavailable' ), 'unknown error', 'error text parsing of bad error';
-my $o2 = Open311->new( endpoint => 'http://192.168.50.1/open311/', jurisdiction => 'example.org' );
+my $o2 = Open311->new( endpoint => 'http://127.0.0.1/open311/', jurisdiction => 'example.org' );
my $u = FixMyStreet::DB->resultset('User')->new( { email => 'test@example.org', name => 'A User' } );
@@ -258,16 +260,26 @@ subtest 'extended request update post parameters' => sub {
};
subtest 'check media url set' => sub {
- $comment->photo(1);
+ my $UPLOAD_DIR = tempdir( CLEANUP => 1 );
+
+ my $image_path = path('t/app/controller/sample.jpg');
+ $image_path->copy( path( $UPLOAD_DIR, '0123456789012345678901234567890123456789.jpeg' ) );
+
+ $comment->photo("0123456789012345678901234567890123456789");
$comment->cobrand('fixmystreet');
- my $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id>248</update_id></request_update></service_request_updates>' );
+ FixMyStreet::override_config {
+ UPLOAD_DIR => $UPLOAD_DIR,
+ }, sub {
+ my $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id>248</update_id></request_update></service_request_updates>' );
- is $results->{ res }, 248, 'got update id';
+ is $results->{ res }, 248, 'got update id';
- 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';
+ my $c = CGI::Simple->new( $results->{ req }->content );
+ my $expected_path = '/c/' . $comment->id . '.0.full.jpeg';
+ like $c->param('media_url'), qr/$expected_path/, 'image url included';
+ };
+ $comment->photo(undef);
};
foreach my $test (