Skip to content

Commit

Permalink
Merge branch 'bexley-whitespace-change-message' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismytton committed Apr 26, 2024
2 parents a636e63 + c45769f commit c08f869
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
7 changes: 7 additions & 0 deletions perllib/Open311/Endpoint/Integration/UK/Bexley/Whitespace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ around BUILDARGS => sub {
return $class->$orig(%args);
};

sub _worksheet_message {
my ($self, $args) = @_;

return "Assisted collection? $args->{attributes}->{assisted_yn}\n\n" .
"Location of containers: $args->{attributes}->{location_of_containers}\n";
}

__PACKAGE__->run_if_script;
8 changes: 7 additions & 1 deletion perllib/Open311/Endpoint/Integration/Whitespace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ sub post_service_request {
uprn => $args->{attributes}->{uprn},
service_item_name => $args->{attributes}->{service_item_name},
worksheet_reference => $args->{attributes}->{fixmystreet_id},
worksheet_message => $args->{description},
worksheet_message => $self->_worksheet_message($args),
assisted_yn => $args->{attributes}->{assisted_yn},
location_of_containers => $args->{attributes}->{location_of_containers},
});
Expand All @@ -94,4 +94,10 @@ sub post_service_request {
return $request;
}

sub _worksheet_message {
my ($self, $args) = @_;

return $args->{description};
}

1;
31 changes: 31 additions & 0 deletions t/open311/endpoint/bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,35 @@ subtest "POST update OK" => sub {
} ], 'correct json returned';
};

subtest "Whitespace worksheets use Bexley's custom message" => sub {
my $ws = Test::MockModule->new('Integrations::Whitespace');
$ws->mock(CreateWorksheet => sub {
my ($self, $args) = @_;
is $args->{worksheet_message}, "Assisted collection? Yes\n\nLocation of containers: location of containers\n";
return 1001;
});
my $res = $endpoint->run_test_request(
POST => '/requests.json',
api_key => 'test',
service_code => 'Whitespace-WS1',
first_name => 'Bob',
last_name => 'Mould',
description => "This is the details",
lat => 51,
long => -1,
'attribute[uprn]' => 1000001,
'attribute[service_item_name]' => 'service item name',
'attribute[fixmystreet_id]' => 'fixmystreet id',
'attribute[assisted_yn]' => 'Yes',
'attribute[location_of_containers]' => 'location of containers',
);
ok $res->is_success, 'valid request'
or diag $res->content;

is_deeply decode_json($res->content),
[ {
"service_request_id" => "Whitespace-1001"
} ], 'correct json returned';
};

done_testing;

0 comments on commit c08f869

Please sign in to comment.