diff options
Diffstat (limited to 't/sendreport')
-rw-r--r-- | t/sendreport/open311.t | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/t/sendreport/open311.t b/t/sendreport/open311.t index 382df39f0..1cec5dd68 100644 --- a/t/sendreport/open311.t +++ b/t/sendreport/open311.t @@ -155,4 +155,45 @@ subtest 'test handles bad category', sub { like $bad_category_report->send_fail_reason, qr/Category Flytipping does not exist for body/, 'failure message set'; }; +my $hounslow = $mech->create_body_ok( 2483, 'Hounslow Borough Council'); +my $contact2 = $mech->create_contact_ok( body_id => $hounslow->id, category => 'Graffiti', email => 'GRAF' ); +$contact2->set_extra_fields( + { code => 'easting', datatype => 'number' }, + { code => 'northing', datatype => 'number' }, + { code => 'fixmystreet_id', datatype => 'number' }, +); +$contact2->update; + +my ($hounslow_report) = $mech->create_problems_for_body( 1, $hounslow->id, 'Test', { + cobrand => 'hounslow', + category => 'Graffiti', + user => $user, + latitude => 51.482286, + longitude => -0.328163, + cobrand => 'hounslow', +}); + +subtest 'Hounslow sends email upon Open311 submission', sub { + $hounslow->update( { send_method => 'Open311', endpoint => 'http://endpoint.example.com', jurisdiction => 'hounslow', api_key => 'test' } ); + $mech->clear_emails_ok; + FixMyStreet::override_config { + STAGING_FLAGS => { send_reports => 1 }, + ALLOWED_COBRANDS => [ 'hounslow' ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + FixMyStreet::Script::Reports::send(); + }; + $hounslow_report->discard_changes; + ok $hounslow_report->whensent, 'Report marked as sent'; + ok $hounslow_report->get_extra_metadata('hounslow_email_sent'), "Enquiries inbox email marked as sent"; + my ($hounslow_email, $user_email) = $mech->get_email; + my $body = $mech->get_text_body_from_email($hounslow_email); + like $body, qr/A user of FixMyStreet has submitted the following report/; + like $body, qr/Category: Graffiti/; + like $body, qr/Enquiry ref: 248/; + $body = $mech->get_text_body_from_email($user_email); + like $body, qr/reference number is 248/; +}; + + done_testing(); |