diff options
Diffstat (limited to 't')
-rw-r--r-- | t/cobrand/bathnes.t | 15 | ||||
-rw-r--r-- | t/cobrand/bristol.t | 10 | ||||
-rw-r--r-- | t/sendreport/open311.t | 41 |
3 files changed, 65 insertions, 1 deletions
diff --git a/t/cobrand/bathnes.t b/t/cobrand/bathnes.t index 6586dcb96..1ebddd05a 100644 --- a/t/cobrand/bathnes.t +++ b/t/cobrand/bathnes.t @@ -11,7 +11,7 @@ my $counciluser = $mech->create_user_ok('counciluser@example.com', name => 'Coun my $normaluser = $mech->create_user_ok('normaluser@example.com', name => 'Normal User'); $normaluser->update({ phone => "+447123456789" }); -$mech->create_problems_for_body(1, $body->id, 'Title', { +my ($problem) = $mech->create_problems_for_body(1, $body->id, 'Title', { areas => ",2651,", category => 'Potholes', cobrand => 'fixmystreet', user => $normaluser, service => 'iOS', extra => { _fields => [ @@ -199,4 +199,17 @@ subtest 'extra CSV columns are present if permission granted' => sub { }; +subtest 'check cobrand correctly reset on each request' => sub { + FixMyStreet::override_config { + 'ALLOWED_COBRANDS' => [ 'bathnes', 'fixmystreet' ], + }, sub { + $mech->log_in_ok( $superuser->email ); + $mech->host('www.fixmystreet.com'); + $mech->get_ok( '/contact?id=' . $problem->id ); + $mech->host('bathnes.fixmystreet.com'); + $mech->get_ok( '/contact?reject=1&id=' . $problem->id ); + $mech->content_contains('Reject report'); + } +}; + done_testing(); diff --git a/t/cobrand/bristol.t b/t/cobrand/bristol.t index b2b8cff13..d4770b6ee 100644 --- a/t/cobrand/bristol.t +++ b/t/cobrand/bristol.t @@ -21,6 +21,16 @@ my $email_contact = $mech->create_contact_ok( send_method => 'Email' ); +subtest 'Reports page works with no reports', sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'bristol' ], + MAPIT_URL => 'http://mapit.uk/', + MAP_TYPE => 'Bristol', + }, sub { + $mech->get_ok("/reports"); + }; +}; + subtest 'Only Open311 categories are shown on Bristol cobrand', sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'bristol' ], 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(); |