diff options
Diffstat (limited to 't')
-rw-r--r-- | t/cobrand/westminster.t | 30 | ||||
-rw-r--r-- | t/sendreport/open311.t | 41 |
2 files changed, 57 insertions, 14 deletions
diff --git a/t/cobrand/westminster.t b/t/cobrand/westminster.t index 1ceeef6cb..cadd6b18d 100644 --- a/t/cobrand/westminster.t +++ b/t/cobrand/westminster.t @@ -162,21 +162,23 @@ FixMyStreet::override_config { }; }; -FixMyStreet::override_config { - ALLOWED_COBRANDS => 'westminster', - MAPIT_URL => 'http://mapit.uk/', -}, sub { - subtest 'No reporter alert created' => sub { - my $user = $mech->log_in_ok('test@example.org'); - $mech->get_ok('/'); - $mech->submit_form_ok( { with_fields => { pc => 'SW1A1AA' } }, "submit location" ); - $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" ); - $mech->submit_form_ok( { with_fields => { - title => 'Title', detail => 'Detail', category => 'Abandoned bike', name => 'Test Example', - } }, 'submitted okay' ); - is $user->alerts->count, 0; +for my $cobrand (qw(westminster fixmystreet)) { + FixMyStreet::override_config { + ALLOWED_COBRANDS => $cobrand, + MAPIT_URL => 'http://mapit.uk/', + }, sub { + subtest "No reporter alert created in $cobrand" => sub { + my $user = $mech->log_in_ok('test@example.org'); + $mech->get_ok('/'); + $mech->submit_form_ok( { with_fields => { pc => 'SW1A1AA' } }, "submit location" ); + $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" ); + $mech->submit_form_ok( { with_fields => { + title => 'Title', detail => 'Detail', category => 'Abandoned bike', name => 'Test Example', + } }, 'submitted okay' ); + is $user->alerts->count, 0; + }; }; -}; +} my $westminster = FixMyStreet::Cobrand::Westminster->new; subtest 'correct config returned for USRN/UPRN lookup' => sub { 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(); |