aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2018-10-26 11:25:01 +0100
committerStruan Donald <struan@exo.org.uk>2018-11-19 13:27:43 +0000
commit0e8c7453c40db5ade085fb759ba73fb8ecf9b18d (patch)
treedb38c5676a712bc47a12d5fa7e58f2d10042431d /t
parentb97ea167b85dab9ef6a3781e24a457b392f4154c (diff)
[UK] send reports on highways agency roads to highways agency
Includes an option to send to the council instead for e.g. reports on underpasses or bridges. Fixes #736
Diffstat (limited to 't')
-rw-r--r--t/app/controller/report_new.t13
-rw-r--r--t/app/sendreport/email/highways.t32
2 files changed, 45 insertions, 0 deletions
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 6dce6711b..c2e731e61 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -41,6 +41,7 @@ for my $body (
{ area_id => 2227, name => 'Hampshire County Council' },
{ area_id => 2333, name => 'Hart Council' },
{ area_id => 2535, name => 'Sandwell Borough Council' },
+ { area_id => 1000, name => 'Highways England' },
) {
my $body_obj = $mech->create_body_ok($body->{area_id}, $body->{name});
push @bodies, $body_obj;
@@ -98,6 +99,11 @@ my $contact10 = $mech->create_contact_ok(
category => 'Street lighting',
email => 'streetlights-2326@example.com',
);
+my $contact11 = $mech->create_contact_ok(
+ body_id => $body_ids{1000}, # Highways
+ category => 'Pothole',
+ email => 'pothole-1000@example.com',
+);
# test that the various bit of form get filled in and errors correctly
# generated.
@@ -977,6 +983,13 @@ foreach my $test (
extra_fields => { do_not_send => 'Gloucestershire County Council' },
email_count => 1,
},
+ {
+ desc => "test single_body_only with Highways England",
+ category => 'Street lighting',
+ councils => [ 1000 ],
+ extra_fields => { single_body_only => 'Highways England' },
+ email_count => 1,
+ },
) {
subtest $test->{desc} => sub {
diff --git a/t/app/sendreport/email/highways.t b/t/app/sendreport/email/highways.t
new file mode 100644
index 000000000..f53062336
--- /dev/null
+++ b/t/app/sendreport/email/highways.t
@@ -0,0 +1,32 @@
+use FixMyStreet::SendReport::Email::Highways;
+use FixMyStreet::TestMech;
+
+my $mech = FixMyStreet::TestMech->new;
+
+my $bromley = $mech->create_body_ok(2482, 'Bromley Council');
+my $highways = $mech->create_body_ok(2482, 'Highways England');
+
+$mech->create_contact_ok(email => 'council@example.com', body_id => $bromley->id, category => 'Graffiti');
+$mech->create_contact_ok(email => 'council@example.com', body_id => $bromley->id, category => 'Faulty street light');
+$mech->create_contact_ok(email => 'highways@example.com', body_id => $highways->id, category => 'Pothole');
+
+my $row = FixMyStreet::DB->resultset('Problem')->new( {
+ bodies_str => '1000',
+ category => 'Pothole',
+ cobrand => '',
+} );
+
+my $e = FixMyStreet::SendReport::Email::Highways->new;
+is $e->build_recipient_list($row), undef, 'no recipients if no body';
+
+$e = FixMyStreet::SendReport::Email::Highways->new;
+$e->add_body($bromley);
+is $e->build_recipient_list($row), undef, 'no recipients if category missing';
+
+$e = FixMyStreet::SendReport::Email::Highways->new;
+$e->add_body($highways);
+is $e->build_recipient_list($row), 1, 'correct recipient list count';
+is_deeply $e->to, [ [ 'highways@example.com', 'Highways England' ] ], 'correct To line';
+
+done_testing();
+