Skip to content

Commit ed9a799

Browse files
committed
[Sutton] Only allow bulky if service unit present.
1 parent 8f0ac6c commit ed9a799

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

perllib/FixMyStreet/Cobrand/Kingston.pm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,18 @@ Kingston starts collections at 6:30am, and lets you cancel up until then.
484484
485485
=cut
486486

487+
sub bulky_allowed_property {
488+
my ( $self, $property ) = @_;
489+
490+
return if $property->{has_no_services};
491+
my $cfg = $self->feature('echo');
492+
493+
my $type = $property->{type_id} || 0;
494+
my $valid_type = grep { $_ == $type } @{ $cfg->{bulky_address_types} || [] };
495+
my $domestic_farm = $type != 7 || $property->{domestic_refuse_bin};
496+
return $self->bulky_enabled && $valid_type && $domestic_farm;
497+
}
498+
487499
sub bulky_collection_time { { hours => 6, minutes => 30 } }
488500
sub bulky_cancellation_cutoff_time { { hours => 6, minutes => 30, days_before => 0 } }
489501

perllib/FixMyStreet/Cobrand/Sutton.pm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,14 @@ Sutton starts collections at 6am, and lets you cancel up until 6am.
445445
446446
=cut
447447

448+
sub bulky_allowed_property {
449+
my ( $self, $property ) = @_;
450+
my $cfg = $self->feature('echo');
451+
my $type = $property->{type_id} || 0;
452+
my $valid_type = grep { $_ == $type } @{ $cfg->{bulky_address_types} || [] };
453+
return $self->bulky_enabled && $property->{has_bulky_service} && $valid_type;
454+
}
455+
448456
sub bulky_collection_time { { hours => 6, minutes => 0 } }
449457
sub bulky_cancellation_cutoff_time { { hours => 6, minutes => 0, days_before => 0 } }
450458

perllib/FixMyStreet/Roles/Cobrand/SLWP.pm

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -637,18 +637,6 @@ sub bulky_show_location_field_mandatory { 1 }
637637

638638
sub bulky_can_refund { 0 }
639639

640-
sub bulky_allowed_property {
641-
my ( $self, $property ) = @_;
642-
643-
return if $property->{has_no_services};
644-
my $cfg = $self->feature('echo');
645-
646-
my $type = $property->{type_id} || 0;
647-
my $valid_type = grep { $_ == $type } @{ $cfg->{bulky_address_types} || [] };
648-
my $domestic_farm = $type != 7 || $property->{domestic_refuse_bin};
649-
return $self->bulky_enabled && $valid_type && $domestic_farm;
650-
}
651-
652640
sub collection_date {
653641
my ($self, $p) = @_;
654642
return $self->_bulky_date_to_dt($p->get_extra_field_value('Collection_Date'));

t/app/controller/waste_kands_bulky.t

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,6 @@ FixMyStreet::override_config {
818818
);
819819

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

@@ -877,6 +876,15 @@ FixMyStreet::override_config {
877876
};
878877
});
879878

879+
$echo->mock( 'GetServiceUnitsForObject', sub { [{'ServiceId' => 2238}] } );
880+
881+
subtest 'No bulky service, no option' => sub {
882+
$mech->get_ok('/waste/12346/');
883+
$mech->content_lacks('Bulky Waste');
884+
};
885+
886+
$echo->mock( 'GetServiceUnitsForObject', sub { [{'ServiceId' => 2238}, {'ServiceId' => 413}] } );
887+
880888
subtest 'Sutton specific Bulky Waste text' => sub {
881889
$mech->get_ok('/waste/12346/');
882890
$mech->content_contains('Bulky Waste');

0 commit comments

Comments
 (0)