diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-08-03 23:31:45 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-08-07 15:07:27 +0100 |
commit | 905bca8561bd85905945ddd33d6a8ae119c76e3c (patch) | |
tree | 81c08c274afe02e01cba879ea3884fc5bf2204bc /t/cobrand | |
parent | e46125e56cb922ebe8bbae527a53d06b28c173cc (diff) |
[Buckinghamshire] Update flytipping handling.
Allow flytipping reporting on cobrand and .com, with road reports going to
Bucks Confirm and email, and non-road reports going to district and Bucks
emails.
Diffstat (limited to 't/cobrand')
-rw-r--r-- | t/cobrand/bucks.t | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/t/cobrand/bucks.t b/t/cobrand/bucks.t index 882de8179..17e850196 100644 --- a/t/cobrand/bucks.t +++ b/t/cobrand/bucks.t @@ -4,8 +4,15 @@ use FixMyStreet::Script::Reports; my $mech = FixMyStreet::TestMech->new; -my $body = $mech->create_body_ok(2217, 'Buckinghamshire'); -$mech->create_contact_ok(body_id => $body->id, category => 'Flytipping', email => "flytipping\@example.org"); +my $body = $mech->create_body_ok(2217, 'Buckinghamshire', { + send_method => 'Open311', api_key => 'key', endpoint => 'endpoint', jurisdiction => 'fms' }); + +$mech->create_contact_ok(body_id => $body->id, category => 'Flytipping', email => "FLY"); +$mech->create_contact_ok(body_id => $body->id, category => 'Potholes', email => "POT"); + +my $district = $mech->create_body_ok(2257, 'Chiltern'); +$mech->create_contact_ok(body_id => $district->id, category => 'Flytipping', email => "flytipping\@chiltern"); +$mech->create_contact_ok(body_id => $district->id, category => 'Graffiti', email => "graffiti\@chiltern"); my $cobrand = Test::MockModule->new('FixMyStreet::Cobrand::Buckinghamshire'); $cobrand->mock('lookup_site_code', sub { @@ -16,6 +23,7 @@ $cobrand->mock('lookup_site_code', sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'buckinghamshire', 'fixmystreet' ], MAPIT_URL => 'http://mapit.uk/', + STAGING_FLAGS => { send_reports => 1, skip_checks => 0 }, }, sub { subtest 'cobrand displays council name' => sub { @@ -24,7 +32,16 @@ subtest 'cobrand displays council name' => sub { $mech->content_contains('Buckinghamshire'); }; -$mech->create_problems_for_body(1, $body->id, 'On Road', { +subtest 'cobrand displays correct categories' => sub { + my $json = $mech->get_ok_json('/report/new/ajax?latitude=51.615559&longitude=-0.556903'); + is @{$json->{bodies}}, 2, 'Both Chiltern and Bucks returned'; + like $json->{category}, qr/Flytipping/, 'Flytipping displayed'; + unlike $json->{category}, qr/Graffiti/, 'Graffiti not displayed'; + $json = $mech->get_ok_json('/report/new/category_extras?latitude=51.615559&longitude=-0.556903'); + is @{$json->{bodies}}, 2, 'Still both Chiltern and Bucks returned'; +}; + +my ($report) = $mech->create_problems_for_body(1, $body->id, 'On Road', { category => 'Flytipping', cobrand => 'fixmystreet', latitude => 51.812244, longitude => -0.827363, }); @@ -32,19 +49,35 @@ $mech->create_problems_for_body(1, $body->id, 'On Road', { subtest 'flytipping on road sent to extra email' => sub { FixMyStreet::Script::Reports::send(); my $email = $mech->get_email; - my $tfb = join('', 'crmbusinesssupport', '@', 'buckscc.gov.uk'); - is $email->header('To'), '"Buckinghamshire" <flytipping@example.org>, "TfB" <' . $tfb . '>'; + my $tfb = join('', 'illegaldumpingcosts', '@', 'buckscc.gov.uk'); + is $email->header('To'), '"TfB" <' . $tfb . '>'; + $report->discard_changes; + is $report->external_id, 248, 'Report has right external ID'; }; -$mech->create_problems_for_body(1, $body->id, 'Off Road', { +($report) = $mech->create_problems_for_body(1, $body->id, 'On Road', { + category => 'Potholes', cobrand => 'fixmystreet', + latitude => 51.812244, longitude => -0.827363, +}); + +subtest 'pothole on road not sent to extra email' => sub { + $mech->clear_emails_ok; + FixMyStreet::Script::Reports::send(); + $mech->email_count_is(0); + $report->discard_changes; + is $report->external_id, 248, 'Report has right external ID'; +}; + +($report) = $mech->create_problems_for_body(1, $district->id, 'Off Road', { category => 'Flytipping', cobrand => 'fixmystreet', latitude => 51.813173, longitude => -0.826741, }); -subtest 'flytipping on road sent to extra email' => sub { - $mech->clear_emails_ok; +subtest 'flytipping off road sent to extra email' => sub { FixMyStreet::Script::Reports::send(); my $email = $mech->get_email; - is $email->header('To'), '"Buckinghamshire" <flytipping@example.org>'; + is $email->header('To'), '"Chiltern" <flytipping@chiltern>'; + $report->discard_changes; + is $report->external_id, undef, 'Report has right external ID'; }; }; |