Skip to content

Commit

Permalink
[Sutton] Only allow bulky if service unit present.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Jan 24, 2025
1 parent 8f0ac6c commit ed9a799
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
12 changes: 12 additions & 0 deletions perllib/FixMyStreet/Cobrand/Kingston.pm
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,18 @@ Kingston starts collections at 6:30am, and lets you cancel up until then.
=cut

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

return if $property->{has_no_services};
my $cfg = $self->feature('echo');

my $type = $property->{type_id} || 0;
my $valid_type = grep { $_ == $type } @{ $cfg->{bulky_address_types} || [] };
my $domestic_farm = $type != 7 || $property->{domestic_refuse_bin};
return $self->bulky_enabled && $valid_type && $domestic_farm;
}

sub bulky_collection_time { { hours => 6, minutes => 30 } }
sub bulky_cancellation_cutoff_time { { hours => 6, minutes => 30, days_before => 0 } }

Expand Down
8 changes: 8 additions & 0 deletions perllib/FixMyStreet/Cobrand/Sutton.pm
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,14 @@ Sutton starts collections at 6am, and lets you cancel up until 6am.
=cut

sub bulky_allowed_property {
my ( $self, $property ) = @_;
my $cfg = $self->feature('echo');
my $type = $property->{type_id} || 0;
my $valid_type = grep { $_ == $type } @{ $cfg->{bulky_address_types} || [] };
return $self->bulky_enabled && $property->{has_bulky_service} && $valid_type;
}

sub bulky_collection_time { { hours => 6, minutes => 0 } }
sub bulky_cancellation_cutoff_time { { hours => 6, minutes => 0, days_before => 0 } }

Expand Down
12 changes: 0 additions & 12 deletions perllib/FixMyStreet/Roles/Cobrand/SLWP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -637,18 +637,6 @@ sub bulky_show_location_field_mandatory { 1 }

sub bulky_can_refund { 0 }

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

return if $property->{has_no_services};
my $cfg = $self->feature('echo');

my $type = $property->{type_id} || 0;
my $valid_type = grep { $_ == $type } @{ $cfg->{bulky_address_types} || [] };
my $domestic_farm = $type != 7 || $property->{domestic_refuse_bin};
return $self->bulky_enabled && $valid_type && $domestic_farm;
}

sub collection_date {
my ($self, $p) = @_;
return $self->_bulky_date_to_dt($p->get_extra_field_value('Collection_Date'));
Expand Down
10 changes: 9 additions & 1 deletion t/app/controller/waste_kands_bulky.t
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,6 @@ FixMyStreet::override_config {
);

my $echo = Test::MockModule->new('Integrations::Echo');
$echo->mock( 'GetServiceUnitsForObject', sub { [{'ServiceId' => 2238}] } );
$echo->mock( 'GetTasks', sub { [] } );
$echo->mock( 'GetEventsForObject', sub { [] } );

Expand Down Expand Up @@ -877,6 +876,15 @@ FixMyStreet::override_config {
};
});

$echo->mock( 'GetServiceUnitsForObject', sub { [{'ServiceId' => 2238}] } );

subtest 'No bulky service, no option' => sub {
$mech->get_ok('/waste/12346/');
$mech->content_lacks('Bulky Waste');
};

$echo->mock( 'GetServiceUnitsForObject', sub { [{'ServiceId' => 2238}, {'ServiceId' => 413}] } );

subtest 'Sutton specific Bulky Waste text' => sub {
$mech->get_ok('/waste/12346/');
$mech->content_contains('Bulky Waste');
Expand Down

0 comments on commit ed9a799

Please sign in to comment.