aboutsummaryrefslogtreecommitdiffstats
path: root/t/sendreport
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2019-06-06 10:30:52 +0100
committerMatthew Somerville <matthew@mysociety.org>2019-06-20 13:37:49 +0100
commite03c068ecd1b752f68eaa3904a3f4755884078fb (patch)
tree3f5d82a7a050ab148b34f9eea48a13289eb42636 /t/sendreport
parent1aeca7c6130aa6de377c8e00e8d22ae05943e919 (diff)
better error if category for report does not exist
It is possible that the category of a report no longer exists and in that case the Open311 send process was falling over. This checks that we've found a contact and if not sets the error and skips the report.
Diffstat (limited to 't/sendreport')
-rw-r--r--t/sendreport/open311.t22
1 files changed, 22 insertions, 0 deletions
diff --git a/t/sendreport/open311.t b/t/sendreport/open311.t
index e68a0aa3c..382df39f0 100644
--- a/t/sendreport/open311.t
+++ b/t/sendreport/open311.t
@@ -11,6 +11,7 @@ package main;
use CGI::Simple;
use Path::Tiny;
+use Test::Warn;
use FixMyStreet::Script::Reports;
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
@@ -133,4 +134,25 @@ subtest 'test sending multiple photos', sub {
], 'Multiple photos in media_url';
};
+my ($bad_category_report) = $mech->create_problems_for_body( 1, $body->id, 'Test', {
+ cobrand => 'fixmystreet',
+ category => 'Flytipping',
+ user => $user,
+});
+
+subtest 'test handles bad category', sub {
+ $body->update( { send_method => 'Open311', endpoint => 'http://endpoint.example.com', jurisdiction => 'FMS', api_key => 'test' } );
+ my $test_data;
+ FixMyStreet::override_config {
+ STAGING_FLAGS => { send_reports => 1 },
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $test_data = FixMyStreet::Script::Reports::send();
+ };
+ $bad_category_report->discard_changes;
+ ok !$bad_category_report->whensent, 'Report not marked as sent';
+ like $bad_category_report->send_fail_reason, qr/Category Flytipping does not exist for body/, 'failure message set';
+};
+
done_testing();