aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2019-07-23 15:02:45 +0100
committerDave Arter <davea@mysociety.org>2019-08-16 14:25:12 +0100
commitbef9123a6477ab5c96bf3e86b070a9ce0e91b2c6 (patch)
tree73f540b20e8f1351037560b00f1e77926acc005b
parent1165ca9c88ef65fc46a911cd770d71236f4f2b35 (diff)
[Open311] Include account_id in POST Service Requests if present
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/Open311.pm2
-rw-r--r--t/open311.t30
3 files changed, 33 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1190c81eb..14cc5fe9c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -47,6 +47,7 @@
- Support receiving updates from external source.
- Improve JSON output of controller.
- unset external_status_code if blank in update
+ - Add support for account_id parameter to POST Service Request calls.
* v2.6 (3rd May 2019)
- New features:
diff --git a/perllib/Open311.pm b/perllib/Open311.pm
index ebf3ee987..8ef1a4f2c 100644
--- a/perllib/Open311.pm
+++ b/perllib/Open311.pm
@@ -144,6 +144,8 @@ sub _populate_service_request_params {
$params->{phone} = $problem->user->phone if $problem->user->phone;
$params->{email} = $problem->user->email if $problem->user->email;
+ $params->{account_id} = $extra->{account_id} if defined $extra->{account_id};
+
# Some endpoints don't follow the Open311 spec correctly and require an
# email address for service requests.
if ($self->always_send_email && !$params->{email}) {
diff --git a/t/open311.t b/t/open311.t
index 73bb488d5..9524006b8 100644
--- a/t/open311.t
+++ b/t/open311.t
@@ -263,6 +263,36 @@ for my $test (
};
}
+for my $test (
+ {
+ desc => 'account_id handled correctly when present',
+ account_id => '1c304134-ef12-c128-9212-123908123901',
+ },
+ {
+ desc => 'account_id handled correctly when 0',
+ account_id => '0'
+ },
+ {
+ desc => 'account_id handled correctly when missing',
+ account_id => undef
+ }
+) {
+ subtest $test->{desc} => sub {
+ $problem->extra( undef );
+ my $extra = {
+ url => 'http://example.com/report/1',
+ defined $test->{account_id} ? ( account_id => $test->{account_id} ) : ()
+ };
+
+ 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 $c = CGI::Simple->new( $results->{req}->content );
+
+ is $c->param( 'account_id' ), $test->{account_id}, 'correct account_id';
+ };
+}
+
subtest 'test always_send_email' => sub {
my $email = $user->email;
$user->email(undef);