aboutsummaryrefslogtreecommitdiffstats
path: root/t/open311
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2016-01-27 11:38:59 +0000
committerMatthew Somerville <matthew@mysociety.org>2016-01-29 15:08:18 +0000
commitb4e69645bd2ff24fb603bf7461e2c80b316eaeaa (patch)
tree0b25ff4d36bfe3b9685c8d3818760ab3e41f2950 /t/open311
parent2679b30e530861ba7c2bef6f36a60242872bd6a7 (diff)
Spot media_url in Open311 GetServiceRequestUpdate.
Fixes #1315.
Diffstat (limited to 't/open311')
-rw-r--r--t/open311/getservicerequestupdates.t27
1 files changed, 27 insertions, 0 deletions
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index 46c3feda4..18a5802bb 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -4,6 +4,8 @@ use strict;
use warnings;
use Test::More;
use CGI::Simple;
+use LWP::Protocol::PSGI;
+use t::Mock::Static;
use_ok( 'Open311' );
@@ -363,6 +365,31 @@ for my $test (
};
}
+subtest 'Update with media_url includes image in update' => sub {
+ my $guard = LWP::Protocol::PSGI->register(t::Mock::Static->to_psgi_app, host => 'example.com');
+
+ my $local_requests_xml = $requests_xml;
+ my $updated_datetime = sprintf( '<updated_datetime>%s</updated_datetime>', $dt );
+ $local_requests_xml =~ s/UPDATED_DATETIME/$updated_datetime/;
+ $local_requests_xml =~ s#<service_request_id>\d+</service_request_id>#
+ <service_request_id>@{[$problem->external_id]}</service_request_id>
+ <media_url>http://example.com/image.jpeg</media_url>#;
+
+ my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } );
+
+ $problem->comments->delete;
+ $problem->lastupdate( DateTime->now()->subtract( days => 1 ) );
+ $problem->state('confirmed');
+ $problem->update;
+
+ my $update = Open311::GetServiceRequestUpdates->new( system_user => $user );
+ $update->update_comments( $o, $bodies{2482} );
+
+ is $problem->comments->count, 1, 'comment count';
+ my $c = $problem->comments->first;
+ is $c->external_id, 638344;
+ is $c->photo, '1cdd4329ceee2234bd4e89cb33b42061a0724687', 'photo exists';
+};
foreach my $test (
{