diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/sendreport/email/highways.t | 1 | ||||
-rw-r--r-- | t/app/sendreport/email/tfl.t | 1 | ||||
-rw-r--r-- | t/open311/getservicerequestupdates.t | 33 | ||||
-rw-r--r-- | t/sendreport/open311.t | 22 |
4 files changed, 56 insertions, 1 deletions
diff --git a/t/app/sendreport/email/highways.t b/t/app/sendreport/email/highways.t index f53062336..452dda822 100644 --- a/t/app/sendreport/email/highways.t +++ b/t/app/sendreport/email/highways.t @@ -11,6 +11,7 @@ $mech->create_contact_ok(email => 'council@example.com', body_id => $bromley->id $mech->create_contact_ok(email => 'highways@example.com', body_id => $highways->id, category => 'Pothole'); my $row = FixMyStreet::DB->resultset('Problem')->new( { + id => 123, bodies_str => '1000', category => 'Pothole', cobrand => '', diff --git a/t/app/sendreport/email/tfl.t b/t/app/sendreport/email/tfl.t index 0322de551..8c6eeffa0 100644 --- a/t/app/sendreport/email/tfl.t +++ b/t/app/sendreport/email/tfl.t @@ -11,6 +11,7 @@ $mech->create_contact_ok(email => 'council@example.com', body_id => $bromley->id $mech->create_contact_ok(email => 'tfl@example.com', body_id => $tfl->id, category => 'Traffic lights'); my $row = FixMyStreet::DB->resultset('Problem')->new( { + id => 456, bodies_str => '1000', category => 'Faulty street light', cobrand => '', diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t index 130b618c9..3cb2fda69 100644 --- a/t/open311/getservicerequestupdates.t +++ b/t/open311/getservicerequestupdates.t @@ -144,7 +144,7 @@ sub create_problem { detail => '', used_map => 1, user_id => 1, - name => '', + name => 'Test User', state => 'confirmed', service => '', cobrand => 'default', @@ -453,6 +453,37 @@ for my $test ( }; } +my $response_template_vars = $bodies{2482}->response_templates->create({ + title => "a placeholder action scheduled template", + text => "We are investigating this report: {{description}}", + auto_response => 1, + state => "action scheduled" +}); +subtest 'Check template placeholders' => sub { + my $local_requests_xml = setup_xml($problem->external_id, $problem->id, 'ACTION_SCHEDULED', 'We will do this in the morning.'); + my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', extended_statuses => undef, test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } ); + + $problem->lastupdate( DateTime->now()->subtract( days => 1 ) ); + $problem->state( 'fixed - council' ); + $problem->update; + + my $update = Open311::GetServiceRequestUpdates->new; + $update->fetch($o); + + is $problem->comments->count, 1, 'comment count'; + $problem->discard_changes; + + my $c = FixMyStreet::DB->resultset('Comment')->search( { external_id => 638344 } )->first; + ok $c, 'comment exists'; + is $c->text, "We are investigating this report: We will do this in the morning.", 'text correct'; + is $c->mark_fixed, 0, 'mark_closed correct'; + is $c->problem_state, 'action scheduled', 'problem_state correct'; + is $c->mark_open, 0, 'mark_open correct'; + is $c->state, 'confirmed', 'comment state correct'; + is $problem->state, 'action scheduled', 'correct problem state'; + $problem->comments->delete; +}; + my $problemB = create_problem($bodies{2237}->id); for my $test ( 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(); |