Skip to content

Commit

Permalink
[Brent] Check presence of garden service unit.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Sep 17, 2024
1 parent 2eb0466 commit 18d042a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
9 changes: 9 additions & 0 deletions perllib/FixMyStreet/Cobrand/Brent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,15 @@ sub garden_container_data_extract {
}
}

sub waste_extra_service_info_all_results {
my ($self, $property, $result) = @_;

if (!(@$result && grep { $_->{ServiceId} == $self->garden_service_id } @$result)) {
# No garden collection possible
$self->{c}->stash->{waste_features}->{garden_disabled} = 1;
}
}

sub waste_extra_service_info {
my ($self, $property, @rows) = @_;

Expand Down
35 changes: 24 additions & 11 deletions t/app/controller/waste_brent_garden.t
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ sub new { my $c = shift; bless { @_ }, $c; }

package main;

sub garden_waste_no_bins {
return [ {
sub food_waste_collection {
return {
Id => 1001,
ServiceId => 316,
ServiceName => 'Food waste collection',
Expand All @@ -99,7 +99,13 @@ sub garden_waste_no_bins {
},
} ] },
} },
}, {
};
}

sub garden_waste_no_bins {
return [
food_waste_collection(),
{
# Eligibility for garden waste, but no task
Id => 1002,
ServiceId => 317,
Expand All @@ -109,21 +115,21 @@ sub garden_waste_no_bins {
}

sub garden_waste_one_sack {
my $refuse_bin = garden_waste_no_bins();
my $refuse_bin = food_waste_collection();
my $garden_bin = _garden_waste_service_units(1, 'sack');
return [ $refuse_bin->[0], $garden_bin->[0] ];
return [ $refuse_bin, $garden_bin ];
}

sub garden_waste_one_bin {
my $refuse_bin = garden_waste_no_bins();
my $refuse_bin = food_waste_collection();
my $garden_bin = _garden_waste_service_units(1, 'bin');
return [ $refuse_bin->[0], $garden_bin->[0] ];
return [ $refuse_bin, $garden_bin ];
}

sub garden_waste_two_bins {
my $refuse_bin = garden_waste_no_bins();
my $refuse_bin = food_waste_collection();
my $garden_bin = _garden_waste_service_units(2, 'bin');
return [ $refuse_bin->[0], $garden_bin->[0] ];
return [ $refuse_bin, $garden_bin ];
}

sub _garden_waste_service_units {
Expand All @@ -135,7 +141,7 @@ sub _garden_waste_service_units {

my $bin_type_id = 1;

return [ {
return {
Id => 1002,
ServiceId => 317,
ServiceName => 'Garden waste collection',
Expand Down Expand Up @@ -167,7 +173,7 @@ sub _garden_waste_service_units {
Ref => { Value => { anyType => [ 567, 890 ] } },
},
} ] },
} } } ];
} } };
}

FixMyStreet::override_config {
Expand Down Expand Up @@ -324,6 +330,13 @@ FixMyStreet::override_config {
$mech->content_contains('Subscribe to Garden waste collection service', 'Subscribe link present if expired');
};

$echo->mock('GetServiceUnitsForObject', [ food_waste_collection() ]);
subtest 'check new sub bin limits' => sub {
$mech->get_ok('/waste/12345/garden');
is $mech->uri->path, '/waste/12345';
$mech->content_lacks('Subscribe to Garden waste collection service');
};

$echo->mock('GetServiceUnitsForObject', \&garden_waste_no_bins);
subtest 'check new sub bin limits' => sub {
$mech->get_ok('/waste/12345/garden');
Expand Down

0 comments on commit 18d042a

Please sign in to comment.