Skip to content

Commit

Permalink
[National Highways] Only cobrand reports in alert.
Browse files Browse the repository at this point in the history
We do not want to include non-NH reports within a NH alert.
  • Loading branch information
dracos committed Feb 7, 2025
1 parent 61e7964 commit 09d08a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions perllib/FixMyStreet/Script/Alerts.pm
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ sub _send_aggregated_alert_phone {
sub alert_check_cobrand {
my ($alert_cobrand, $item_cobrand) = @_;
return 1 if $alert_cobrand ne 'tfl' && $item_cobrand eq 'tfl';
return 1 if $alert_cobrand eq 'highwaysengland' && $item_cobrand ne 'highwaysengland';
return 1 if $alert_cobrand eq 'cyclinguk' && $item_cobrand ne 'cyclinguk';
return 0;
}
Expand Down
21 changes: 20 additions & 1 deletion t/cobrand/highwaysengland.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use FixMyStreet::TestMech;
use FixMyStreet::App;
use FixMyStreet::Script::Alerts;
use FixMyStreet::Script::CSVExport;
use FixMyStreet::Script::Reports;
use FixMyStreet::Cobrand::HighwaysEngland;
Expand Down Expand Up @@ -51,6 +52,14 @@ $mech->create_contact_ok(email => '[email protected]', body_id => $highways->

my $staffuser = $mech->create_user_ok('[email protected]', name => 'Council User', from_body => $highways, password => 'password');

$staffuser->alerts->create({
alert_type => 'council_problems',
parameter => $highways->id,
whensubscribed => DateTime->now->subtract( hours => 1 ),
cobrand => 'highwaysengland',
confirmed => 1,
});

FixMyStreet::DB->resultset("Role")->create({
body => $highways,
name => 'Inspector',
Expand All @@ -69,6 +78,7 @@ FixMyStreet::override_config {
CONTACT_EMAIL => '[email protected]',
COBRAND_FEATURES => {
contact_email => { highwaysengland => '[email protected]' },
contact_name => { highwaysengland => 'National Highways' },
updates_allowed => {
highwaysengland => 'open',
},
Expand Down Expand Up @@ -108,6 +118,7 @@ FixMyStreet::override_config {
like $body, qr/Road: M1/, 'road data included in email';
like $body, qr/Area: Area 1/, 'area data included in email';
unlike $body, qr/FixMyStreet is an independent service/, 'FMS not mentioned in email';
$mech->clear_emails_ok;
};

subtest "check things redacted appropriately" => sub {
Expand Down Expand Up @@ -145,12 +156,12 @@ FixMyStreet::override_config {
$report->cobrand("fixmystreet");
$report->update;

$mech->clear_emails_ok;
FixMyStreet::Script::Reports::send();
$mech->email_count_is(1);
my $email = $mech->get_email;
my $body = $mech->get_text_body_from_email($email);
like $body, qr/FixMyStreet is an independent service/, 'FMS template used for email';
$mech->clear_emails_ok;
};

my ($problem) = $mech->create_problems_for_body(1, $highways->id, 'Title', { created => '2021-11-30T12:34:56' });
Expand Down Expand Up @@ -193,6 +204,14 @@ FixMyStreet::override_config {
$mech->get_ok('/reports/National+Highways');
$mech->content_contains('Hackney');
};

subtest 'Test alerts working okay' => sub {
my ($problem2) = $mech->create_problems_for_body(1, $highways->id, 'Title', { cobrand => 'highwaysengland' });
FixMyStreet::Script::Alerts::send_other();
my $text = $mech->get_text_body_from_email;
unlike $text, qr{report/@{[$problem->id]}};
like $text, qr{report/@{[$problem2->id]}};
};
};

subtest 'Dashboard CSV extra columns' => sub {
Expand Down

0 comments on commit 09d08a7

Please sign in to comment.