Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unset the external_status_code if blank #2573

Merged
merged 1 commit into from Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -39,6 +39,7 @@
- Do not store display-only extra fields on new reports.
- Support receiving updates from external source.
- Improve JSON output of controller.
- unset external_status_code if blank in update

* v2.6 (3rd May 2019)
- New features:
Expand Down
2 changes: 2 additions & 0 deletions perllib/Open311/GetServiceRequestUpdates.pm
Expand Up @@ -181,6 +181,8 @@ sub process_update {
if ( $external_status_code ) {
$comment->set_extra_metadata(external_status_code => $external_status_code);
$p->set_extra_metadata(external_status_code => $external_status_code);
} else {
$p->set_extra_metadata(external_status_code => '');
}

# if the customer reference to display in the report metadata is
Expand Down
30 changes: 30 additions & 0 deletions t/open311/getservicerequestupdates.t
Expand Up @@ -874,6 +874,36 @@ subtest 'check that external_status_code is stored correctly' => sub {

is $problem->get_extra_metadata('external_status_code'), "101", "correct external status code";

$requests_xml = qq{<?xml version="1.0" encoding="utf-8"?>
<service_requests_updates>
<request_update>
<update_id>638364</update_id>
<service_request_id>@{[ $problem->external_id ]}</service_request_id>
<status>open</status>
<description>This is a note</description>
<updated_datetime>UPDATED_DATETIME</updated_datetime>
<external_status_code></external_status_code>
</request_update>
</service_requests_updates>
};

$problem->comments->delete;

my $dt3 = $dt->clone->add( minutes => 1 );
$requests_xml =~ s/UPDATED_DATETIME/$dt3/;

$o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $requests_xml } );

$update = Open311::GetServiceRequestUpdates->new(
system_user => $user,
current_open311 => $o,
current_body => $bodies{2482},
);

$update->process_body;

$problem->discard_changes;
is $problem->get_extra_metadata('external_status_code'), '', "external status code unset";
};

subtest 'check that external_status_code triggers auto-responses' => sub {
Expand Down