aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2018-03-19 14:36:23 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-03-21 13:18:54 +0000
commitbe61e9162a225323e5840227980b45cc16cdd497 (patch)
tree525f69838367f4e1f05d778028d8238a457726ae /t/cobrand
parent9ceb7bb9a503b38a2947a00a2e656089e72feec7 (diff)
send easting/northing over open311 if send_notpinpointed and no map/postcode
If the map was not clicked and we don't have a postcode we should still send the easting and northing extra attributes if send_notpinpointed is set.
Diffstat (limited to 't/cobrand')
-rw-r--r--t/cobrand/bromley.t72
1 files changed, 50 insertions, 22 deletions
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index 41e351dea..a92786b18 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -46,29 +46,57 @@ $mech->content_contains( 'State changed to: In progress' );
$mech->content_contains( 'marks it as unable to fix' );
$mech->content_contains( 'State changed to: No further action' );
-subtest 'testing special Open311 behaviour', sub {
- $report->set_extra_fields();
- $report->update;
- $body->update( { send_method => 'Open311', endpoint => 'http://bromley.endpoint.example.com', jurisdiction => 'FMS', api_key => 'test', send_comments => 1 } );
- my $test_data;
- FixMyStreet::override_config {
- STAGING_FLAGS => { send_reports => 1 },
- ALLOWED_COBRANDS => [ 'fixmystreet', 'bromley' ],
- }, sub {
- $test_data = FixMyStreet::Script::Reports::send();
- };
- $report->discard_changes;
- ok $report->whensent, 'Report marked as sent';
- is $report->send_method_used, 'Open311', 'Report sent via Open311';
- is $report->external_id, 248, 'Report has right external ID';
+for my $test (
+ {
+ desc => 'testing special Open311 behaviour',
+ updates => {},
+ expected => {
+ 'attribute[easting]' => 529025,
+ 'attribute[northing]' => 179716,
+ 'attribute[service_request_id_ext]' => $report->id,
+ 'jurisdiction_id' => 'FMS',
+ address_id => undef,
+ },
+ },
+ {
+ desc => 'testing Open311 behaviour with no map click or postcode',
+ updates => {
+ used_map => 0,
+ postcode => ''
+ },
+ expected => {
+ 'attribute[easting]' => 529025,
+ 'attribute[northing]' => 179716,
+ 'attribute[service_request_id_ext]' => $report->id,
+ 'jurisdiction_id' => 'FMS',
+ 'address_id' => '#NOTPINPOINTED#',
+ },
+ },
+) {
+ subtest $test->{desc}, sub {
+ $report->set_extra_fields();
+ $report->$_($test->{updates}->{$_}) for keys %{$test->{updates}};
+ $report->$_(undef) for qw/ whensent send_method_used external_id /;
+ $report->update;
+ $body->update( { send_method => 'Open311', endpoint => 'http://bromley.endpoint.example.com', jurisdiction => 'FMS', api_key => 'test', send_comments => 1 } );
+ my $test_data;
+ FixMyStreet::override_config {
+ STAGING_FLAGS => { send_reports => 1 },
+ ALLOWED_COBRANDS => [ 'fixmystreet', 'bromley' ],
+ }, sub {
+ $test_data = FixMyStreet::Script::Reports::send();
+ };
+ $report->discard_changes;
+ ok $report->whensent, 'Report marked as sent';
+ is $report->send_method_used, 'Open311', 'Report sent via Open311';
+ is $report->external_id, 248, 'Report has right external ID';
- my $req = $test_data->{test_req_used};
- my $c = CGI::Simple->new($req->content);
- is $c->param('attribute[easting]'), 529025, 'Request had easting';
- is $c->param('attribute[northing]'), 179716, 'Request had northing';
- is $c->param('attribute[service_request_id_ext]'), $report->id, 'Request had correct ID';
- is $c->param('jurisdiction_id'), 'FMS', 'Request had correct jurisdiction';
-};
+ my $req = $test_data->{test_req_used};
+ my $c = CGI::Simple->new($req->content);
+ is $c->param($_), $test->{expected}->{$_}, "Request had correct $_"
+ for keys %{$test->{expected}};
+ };
+}
for my $test (
{