Skip to content

Commit

Permalink
[Waste] Ignore any other bodies returned.
Browse files Browse the repository at this point in the history
The Merton body covers Kingston’s area due to an out-of-area park which
is Merton’s responsibility. We do not care about this for waste.
  • Loading branch information
dracos committed Jan 6, 2025
1 parent 64a5ad8 commit 4a07727
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions perllib/FixMyStreet/Cobrand/UKCouncils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,12 @@ sub munge_reports_category_list {
sub munge_report_new_bodies {
my ($self, $bodies) = @_;

if ($self->{c}->action =~ /^waste/) {
my $body_id = $self->body->id;
%$bodies = map { $_->id => $_ } grep { $_->id eq $body_id } values %$bodies;
return;

Check warning on line 407 in perllib/FixMyStreet/Cobrand/UKCouncils.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/UKCouncils.pm#L405-L407

Added lines #L405 - L407 were not covered by tests
}

my %bodies = map { $_->get_column('name') => 1 } values %$bodies;
if ( $bodies{'TfL'} ) {
# Presented categories vary if we're on/off a red route
Expand Down
8 changes: 8 additions & 0 deletions t/app/controller/waste_kingston_r.t
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ create_contact({ category => 'Request new container', email => '1635' }, 'Waste'
{ code => 'payment', required => 0, automated => 'hidden_field' },
);

# Merton also covers Kingston because of an out-of-area park which is their responsibility
my $merton = $mech->create_body_ok(2500, 'Merton Council');
FixMyStreet::DB->resultset('BodyArea')->create({ area_id => 2480, body_id => $merton->id });
my $contact = $mech->create_contact_ok(body => $merton, category => 'Report missed collection', email => 'missed');
$contact->set_extra_metadata( type => 'waste' );
$contact->update;

my ($sent_params, $sent_data);

FixMyStreet::override_config {
Expand Down Expand Up @@ -356,6 +363,7 @@ FixMyStreet::override_config {
is $report->get_extra_field_value('uprn'), 1000000002;
is $report->detail, "Report missed Food waste\n\n2 Example Street, Kingston, KT1 1AA";
is $report->title, 'Report missed Food waste';
is $report->bodies_str, $kingston->id, 'correct bodies_str';
};
subtest 'No reporting/requesting if open request' => sub {
$mech->get_ok('/waste/12345');
Expand Down

0 comments on commit 4a07727

Please sign in to comment.