diff options
author | Struan Donald <struan@exo.org.uk> | 2018-09-11 12:47:54 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2018-10-01 07:57:22 +0100 |
commit | d66a953b31c3617ffa8c1af969fcc973732f231c (patch) | |
tree | c8c3072be01f67b9c7e788a9d8182685f3707f8e /t/open311 | |
parent | 4df175118be040ea5457850d59071e40ba3d48e8 (diff) |
[Open311] add customer reference from update to problem
If an Open311 update has a customer_reference property then add that to
the metadata for the problem.
Diffstat (limited to 't/open311')
-rw-r--r-- | t/open311/getservicerequestupdates.t | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t index 9383b8476..995338063 100644 --- a/t/open311/getservicerequestupdates.t +++ b/t/open311/getservicerequestupdates.t @@ -521,6 +521,29 @@ subtest 'Update with media_url includes image in update' => sub { $problem->comments->delete; }; +subtest 'Update with customer_reference adds reference to problem' => sub { + my $guard = LWP::Protocol::PSGI->register(t::Mock::Static->to_psgi_app, host => 'example.com'); + + my $local_requests_xml = setup_xml($problem->external_id, 1, ""); + $local_requests_xml =~ s#</service_request_id>#</service_request_id> + <customer_reference>REFERENCE</customer_reference>#; + my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } ); + + $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} ); + + $problem->discard_changes; + is $problem->comments->count, 1, 'comment count'; + my $c = $problem->comments->first; + is $c->external_id, 638344; + is $problem->get_extra_metadata('customer_reference'), 'REFERENCE'; + $problem->comments->delete; +}; + subtest 'date for comment correct' => sub { my $local_requests_xml = setup_xml($problem->external_id, $problem->id, ""); my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } ); |