Skip to content

Commit

Permalink
[Brent] Use task schedule description for food waste.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Sep 27, 2023
1 parent dfa9170 commit 7a25a36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
5 changes: 4 additions & 1 deletion perllib/FixMyStreet/Cobrand/Brent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,10 @@ sub bin_services_for_address {
my %expired;
foreach (@$result) {
my $servicetask = $self->_get_current_service_task($_) or next;
my $schedules = _parse_schedules($servicetask);
my $desc_to_use = 'schedule';
# Brent has two overlapping schedules for food
$desc_to_use = 'task' if $_->{ServiceId} == 316;
my $schedules = _parse_schedules($servicetask, $desc_to_use);
$expired{$_->{Id}} = $schedules if $self->waste_sub_overdue( $schedules->{end_date}, weeks => 4 );

next unless $schedules->{next} or $schedules->{last};
Expand Down
28 changes: 10 additions & 18 deletions t/cobrand/brent.t
Original file line number Diff line number Diff line change
Expand Up @@ -833,17 +833,18 @@ FixMyStreet::override_config {
ServiceName => 'Domestic Food Waste Collection',
ServiceTasks => { ServiceTask => {
Id => 403,
ScheduleDescription => 'every Thursday',
ServiceTaskSchedules => { ServiceTaskSchedule => {
ScheduleDescription => 'every other Wednesday',
ScheduleDescription => 'every other Thursday',
StartDate => { DateTime => '2020-01-01T00:00:00Z' },
EndDate => { DateTime => '2050-01-01T00:00:00Z' },
NextInstance => {
CurrentScheduledDate => { DateTime => '2020-06-03T00:00:00Z' },
OriginalScheduledDate => { DateTime => '2020-06-03T00:00:00Z' },
CurrentScheduledDate => { DateTime => '2020-06-04T00:00:00Z' },
OriginalScheduledDate => { DateTime => '2020-06-04T00:00:00Z' },
},
LastInstance => {
OriginalScheduledDate => { DateTime => '2020-05-18T00:00:00Z' },
CurrentScheduledDate => { DateTime => '2020-05-20T00:00:00Z' },
CurrentScheduledDate => { DateTime => '2020-05-21T00:00:00Z' },
Ref => { Value => { anyType => [ 345, 678 ] } },
},
TimeBand => {
Expand Down Expand Up @@ -894,20 +895,11 @@ FixMyStreet::override_config {
restore_time();
};

subtest 'shows time band' => sub {
$mech->get_ok('/waste/12345');
$mech->content_contains("(07:30–08:30)");
};

subtest 'showing PDF calendar' => sub {
$mech->get_ok('/waste/12345');
$mech->content_contains('https://example.org/media/16420712/fridayweek2');
};

subtest 'showing green garden waste PDF calendar' => sub {
$mech->get_ok('/waste/12345');
$mech->content_contains('https://example.org/media/16420712/mondayweek2');
};
$mech->get_ok('/waste/12345');
$mech->content_contains("(07:30–08:30)", 'shows time band');
$mech->content_contains('https://example.org/media/16420712/fridayweek2', 'showing PDF calendar');
$mech->content_contains('https://example.org/media/16420712/mondayweek2', 'showing green garden waste PDF calendar');
$mech->content_contains('every Thursday', 'food showing right schedule');

subtest 'test requesting a container' => sub {
$mech->log_in_ok($user1->email);
Expand Down

0 comments on commit 7a25a36

Please sign in to comment.