aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/sendreport/email/highways.t
blob: 452dda82284a3e4c8f8e3ad386756d6e2f34702f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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( {
    id => 123,
    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();