Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[National Highways] Only include NH reports in alerts #5344

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading