aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand/bexley.t
diff options
context:
space:
mode:
Diffstat (limited to 't/cobrand/bexley.t')
-rw-r--r--t/cobrand/bexley.t75
1 files changed, 59 insertions, 16 deletions
diff --git a/t/cobrand/bexley.t b/t/cobrand/bexley.t
index 2f74ac03a..07d7ed91b 100644
--- a/t/cobrand/bexley.t
+++ b/t/cobrand/bexley.t
@@ -30,11 +30,16 @@ my $mech = FixMyStreet::TestMech->new;
my $body = $mech->create_body_ok(2494, 'London Borough of Bexley', {
send_method => 'Open311', api_key => 'key', 'endpoint' => 'e', 'jurisdiction' => 'j' });
$mech->create_contact_ok(body_id => $body->id, category => 'Abandoned and untaxed vehicles', email => "ABAN");
+$mech->create_contact_ok(body_id => $body->id, category => 'Lamp post', email => "LAMP");
+$mech->create_contact_ok(body_id => $body->id, category => 'Parks and open spaces', email => "PARK");
+$mech->create_contact_ok(body_id => $body->id, category => 'Dead animal', email => "ANIM");
+$mech->create_contact_ok(body_id => $body->id, category => 'Something dangerous', email => "DANG");
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'bexley' ],
MAPIT_URL => 'http://mapit.uk/',
STAGING_FLAGS => { send_reports => 1, skip_checks => 0 },
+ COBRAND_FEATURES => { open311_email => { bexley => { p1 => 'p1@bexley', lighting => 'thirdparty@notbexley.example.com' } } },
}, sub {
subtest 'cobrand displays council name' => sub {
@@ -48,24 +53,62 @@ FixMyStreet::override_config {
$mech->content_contains('Bexley');
};
- my ($report) = $mech->create_problems_for_body(1, $body->id, 'On Road', {
- category => 'Abandoned and untaxed vehicles', cobrand => 'bexley',
- latitude => 51.408484, longitude => 0.074653,
- });
- $report->set_extra_fields({ 'name' => 'burnt', description => 'Was it burnt?', 'value' => 'Yes' });
- $report->update;
+ foreach my $test (
+ { category => 'Abandoned and untaxed vehicles', email => 1, code => 'ABAN',
+ extra => { 'name' => 'burnt', description => 'Was it burnt?', 'value' => 'Yes' } },
+ { category => 'Abandoned and untaxed vehicles', code => 'ABAN',
+ extra => { 'name' => 'burnt', description => 'Was it burnt?', 'value' => 'No' } },
+ { category => 'Dead animal', email => 1, code => 'ANIM' },
+ { category => 'Something dangerous', email => 1, code => 'DANG',
+ extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' } },
+ { category => 'Something dangerous', code => 'DANG',
+ extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'No' } },
+ { category => 'Parks and open spaces', email => 1, code => 'PARK',
+ extra => { 'name' => 'reportType', description => 'Type of report', 'value' => 'Wild animal' } },
+ { category => 'Parks and open spaces', code => 'PARK',
+ extra => { 'name' => 'reportType', description => 'Type of report', 'value' => 'Maintenance' } },
+ { category => 'Parks and open spaces', code => 'PARK',
+ extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' } },
+ { category => 'Parks and open spaces', email => 1, code => 'PARK',
+ extra => [
+ { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' },
+ { 'name' => 'reportType', description => 'Type of report', 'value' => 'Vandalism' },
+ ] },
+ { category => 'Lamp post', code => 'LAMP', email => 'thirdparty',
+ extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'No' } },
+ { category => 'Lamp post', code => 'LAMP', email => 'p1.*thirdparty',
+ extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' } },
+ ) {
+ my ($report) = $mech->create_problems_for_body(1, $body->id, 'On Road', {
+ category => $test->{category}, cobrand => 'bexley',
+ latitude => 51.408484, longitude => 0.074653,
+ });
+ if ($test->{extra}) {
+ $report->set_extra_fields(ref $test->{extra} eq 'ARRAY' ? @{$test->{extra}} : $test->{extra});
+ $report->update;
+ }
- subtest 'Server-side NSGRef included' => sub {
- my $test_data = FixMyStreet::Script::Reports::send();
- my $req = $test_data->{test_req_used};
- my $c = CGI::Simple->new($req->content);
- is $c->param('service_code'), 'ABAN';
- is $c->param('attribute[NSGRef]'), 'Road ID';
+ subtest 'NSGRef and correct email config' => sub {
+ my $test_data = FixMyStreet::Script::Reports::send();
+ my $req = $test_data->{test_req_used};
+ my $c = CGI::Simple->new($req->content);
+ is $c->param('service_code'), $test->{code};
+ is $c->param('attribute[NSGRef]'), 'Road ID';
- my $email = $mech->get_email;
- like $email->header('To'), qr/"Bexley P1 email".*bexley/;
- like $mech->get_text_body_from_email($email), qr/NSG Ref: Road ID/;
- };
+ if (my $t = $test->{email}) {
+ my $email = $mech->get_email;
+ if ($t eq 1) {
+ like $email->header('To'), qr/"Bexley P1 email".*bexley/;
+ } else {
+ like $email->header('To'), qr/$t/;
+ }
+ like $mech->get_text_body_from_email($email), qr/NSG Ref: Road ID/;
+ $mech->clear_emails_ok;
+ } else {
+ $mech->email_count_is(0);
+ }
+ };
+ }
};