diff options
author | Struan Donald <struan@exo.org.uk> | 2019-09-05 10:34:54 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2019-09-27 17:35:15 +0100 |
commit | 433474638e33c1320efd0b4826b5d4bbb655d69c (patch) | |
tree | f97b38a1f31c934e9aba041a79395c203df73b40 | |
parent | b1f2ff77da367c06ff4f2c6ac41892131331c70e (diff) |
[IsleOfWight] skip sending urgent field
This is only used to determine if we should block sending the form
-rw-r--r-- | perllib/FixMyStreet/Cobrand/IsleOfWight.pm | 11 | ||||
-rw-r--r-- | t/cobrand/isleofwight.t | 35 |
2 files changed, 46 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/IsleOfWight.pm b/perllib/FixMyStreet/Cobrand/IsleOfWight.pm index 68ed2653e..864e53f36 100644 --- a/perllib/FixMyStreet/Cobrand/IsleOfWight.pm +++ b/perllib/FixMyStreet/Cobrand/IsleOfWight.pm @@ -56,6 +56,17 @@ sub open311_get_update_munging { if !$comment->problem->is_open; } +sub open311_pre_send { + my ($self, $row, $open311) = @_; + + return unless $row->extra; + my $extra = $row->get_extra_fields; + if (@$extra) { + @$extra = grep { $_->{name} ne 'urgent' } @$extra; + $row->set_extra_fields(@$extra); + } +} + sub open311_config { my ($self, $row, $h, $params) = @_; diff --git a/t/cobrand/isleofwight.t b/t/cobrand/isleofwight.t index 42d5d43ba..4c8e92441 100644 --- a/t/cobrand/isleofwight.t +++ b/t/cobrand/isleofwight.t @@ -21,6 +21,16 @@ my $contact = $mech->create_contact_ok( category => 'Potholes', email => 'pothole@example.org', ); +$contact->set_extra_fields( ( { + code => 'urgent', + datatype => 'string', + description => 'question', + variable => 'true', + required => 'false', + order => 1, + datatype_description => 'datatype', +} ) ); +$contact->update; my $user = $mech->create_user_ok('user@example.org'); my $iow_user = $mech->create_user_ok('iow_user@example.org', from_body => $isleofwight); @@ -194,6 +204,31 @@ subtest "fixing passes along the correct message" => sub { }; }; + +subtest 'Check special Open311 request handling', sub { + my ($p) = $mech->create_problems_for_body(1, $isleofwight->id, 'Title', { category => 'Potholes', latitude => 50.7108, longitude => -1.29573 }); + $p->set_extra_fields({ name => 'urgent', value => 'no'}); + $p->update; + + my $test_data; + FixMyStreet::override_config { + STAGING_FLAGS => { send_reports => 1 }, + ALLOWED_COBRANDS => ['isleofwight' ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $test_data = FixMyStreet::Script::Reports::send(); + }; + + $p->discard_changes; + ok $p->whensent, 'Report marked as sent'; + is $p->send_method_used, 'Open311', 'Report sent via Open311'; + is $p->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[urgent]'), undef, 'no urgent param sent'; +}; + my ($p) = $mech->create_problems_for_body(1, $isleofwight->id, '', { cobrand => 'isleofwight' }); my $alert = FixMyStreet::App->model('DB::Alert')->create( { parameter => $p->id, |