Skip to content

Commit

Permalink
[Brent] Store calculated information for logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Jun 28, 2024
1 parent 62c3a50 commit eba9449
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 6 additions & 3 deletions perllib/FixMyStreet/Cobrand/Brent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ sub open311_extra_data_exclude {

sub open311_pre_send {
my ($self, $row, $open311) = @_;
return 'SKIP' if $row->category eq 'Request new container' && $row->get_extra_field_value('referral');
return 'SKIP' if $row->category eq 'Request new container' && $row->get_extra_field_value('request_referral');
}

=head2 open311_post_send
Expand All @@ -708,7 +708,7 @@ sub open311_post_send {
$row->update({ state => 'investigating' });
}

if ($row->category eq 'Request new container' && $row->get_extra_field_value('referral') && !$row->get_extra_metadata('extra_email_sent')) {
if ($row->category eq 'Request new container' && $row->get_extra_field_value('request_referral') && !$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 ]);
Expand Down Expand Up @@ -1308,8 +1308,11 @@ sub waste_munge_request_data {

my $c = $self->{c};

for (qw(how_long_lived contamination_reports ordered_previously)) {
$c->set_param("request_$_", $data->{$_} || '');
}
if (request_referral($id, $data)) {
$c->set_param('referral', 1);
$c->set_param('request_referral', 1);
}

my $address = $c->stash->{property}->{address};
Expand Down
14 changes: 10 additions & 4 deletions t/cobrand/brent.t
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ create_contact({ category => 'Request new container', email => 'request@example.
{ code => 'PaymentCode', required => 0, automated => 'hidden_field' },
{ code => 'payment_method', required => 1, automated => 'hidden_field' },
{ code => 'payment', required => 1, automated => 'hidden_field' },
{ code => 'referral', required => 0, automated => 'hidden_field' },
{ code => 'request_referral', required => 0, automated => 'hidden_field' },
{ code => 'request_how_long_lived', required => 0, automated => 'hidden_field' },
{ code => 'request_ordered_previously', required => 0, automated => 'hidden_field' },
{ code => 'request_contamination_reports', required => 0, automated => 'hidden_field' },
);
create_contact({ category => 'Assisted collection add', email => 'assisted' },
{ code => 'Notes', description => 'Additional notes', required => 0, datatype => 'text' },
Expand Down Expand Up @@ -1253,8 +1256,8 @@ FixMyStreet::override_config {

sub make_request {
my ($test_name, $reason, $duration, $referral, $emails) = @_;
$test_name = "Making a request, $test_name, $reason" . ($duration ? ", $duration" : "");
subtest $test_name => sub {
my $full_test_name = "Making a request, $test_name, $reason" . ($duration ? ", $duration" : "");
subtest $full_test_name => sub {
$mech->get_ok('/waste/12345/request');
$mech->submit_form_ok({ with_fields => { 'container-choice' => 11 } }, "Choose food caddy");
$mech->submit_form_ok({ with_fields => { 'request_reason' => $reason } });
Expand All @@ -1267,7 +1270,10 @@ FixMyStreet::override_config {
$mech->submit_form_ok({ with_fields => { 'process' => 'summary' } });
$mech->content_contains('Your container request has been sent');
my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first;
is $report->get_extra_field_value('referral'), $referral;
is $report->get_extra_field_value('request_referral'), $referral;
is $report->get_extra_field_value('request_how_long_lived'), $duration;
is $report->get_extra_field_value('request_ordered_previously'), $test_name eq 'Ordered' ? 1 : '';
is $report->get_extra_field_value('request_contamination_reports'), $test_name eq 'Contaminated' ? 3 : '';
FixMyStreet::Script::Reports::send();
my @email = $mech->get_email;
is @email, $emails;
Expand Down

0 comments on commit eba9449

Please sign in to comment.