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

[Oxfordshire] Send additional email on category #5264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions perllib/FixMyStreet/Cobrand/Oxfordshire.pm
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,21 @@ sub report_inspect_update_extra {
}
}

sub open311_post_send {
my ($self, $row, $h, $sender) = @_;

if ($row->category eq 'Trees obstructing traffic light' && !$row->get_extra_metadata('extra_email_sent')) {
my $emails = $self->feature('open311_email');
if (my $dest = $emails->{$row->category}) {
my $sender = FixMyStreet::SendReport::Email->new( to => [ $dest ]);
$sender->send($row, $h);
if ($sender->success) {
$row->update_extra_metadata(extra_email_sent => 1);
}
}
}
}

sub on_map_default_status { return 'open'; }

sub around_nearby_filter {
Expand Down
35 changes: 35 additions & 0 deletions t/cobrand/oxfordshire.t
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,39 @@ FixMyStreet::override_config {
};
};

FixMyStreet::override_config {
ALLOWED_COBRANDS => 'oxfordshire',
STAGING_FLAGS => { send_reports => 1 },
COBRAND_FEATURES => {
sub_ward_reporting => { oxfordshire => ['DIW', 'CPC'] },
open311_email => { oxfordshire => { 'Trees obstructing traffic light' => '[email protected]' } }
},
MAPIT_URL => 'http://mapit.uk/',


}, sub {
subtest "Trees obstructing traffic light category sends email too" => sub {
$mech->create_contact_ok( body_id => $oxon->id, category => 'Trees obstructing traffic light', email => 'OPEN311', send_method => 'Open311');
my ($report) = $mech->create_problems_for_body( 1, $oxon->id, 'Traffic light hidden', {
cobrand => 'oxfordshire',
category => 'Trees obstructing traffic light',
latitude => 51.754926,
longitude => -1.256179,
});
FixMyStreet::Script::Reports::send();
my @emails = $mech->get_email;
my $confirm_sent;
for my $email (@emails) {
my %headers = $email->header_str_pairs;
$confirm_sent = 1 if $headers{To} eq '[email protected]';
};
is $confirm_sent, 1, "Traffic light email sent to traffic light email address";
my $req = Open311->test_req_used;
my $c = CGI::Simple->new($req->content);
is $c->{description}[0] =~ /Traffic light hidden/, 1, "Traffic light report also sent to open311";
};

};


done_testing();
Loading