Skip to content

Commit

Permalink
[Peterborough] Check cutoff time in bulky slots.
Browse files Browse the repository at this point in the history
If we are coming back after failed payment or similar, make
sure we're still within the time limit.
  • Loading branch information
dracos committed Dec 18, 2024
1 parent cd508d0 commit 90b926b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions perllib/FixMyStreet/Cobrand/Peterborough/Bulky.pm
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ sub check_bulky_slot_available {
my $workpack_dt = $self->_bulky_date_to_dt($date);
next unless $workpack_dt;

my $now = DateTime->now( time_zone => FixMyStreet->local_time_zone );
my $cutoff = $self->_bulky_cancellation_cutoff_date($workpack_dt);

Check warning on line 198 in perllib/FixMyStreet/Cobrand/Peterborough/Bulky.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Peterborough/Bulky.pm#L197-L198

Added lines #L197 - L198 were not covered by tests
return 0 if $now > $cutoff;

my $date_from = $workpack_dt->clone->strftime('%FT%T');
my $date_to = $workpack_dt->clone->set(
hour => 23,
Expand Down
19 changes: 18 additions & 1 deletion t/app/controller/waste_peterborough_bulky.t
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ FixMyStreet::override_config {
});

my $report;
my $booking_date = '2022-08-01T12:00:00Z';
subtest 'Bulky goods collection booking' => sub {
set_fixed_time($booking_date);
subtest '?type=bulky redirect before any bulky booking made' => sub {
$mech->get_ok('/waste?type=bulky');
is $mech->uri, 'http://localhost/waste?type=bulky',
Expand Down Expand Up @@ -614,7 +616,7 @@ FixMyStreet::override_config {
$mech->content_lacks('/waste/PE1%203NA:100090215480/bulky/cancel/' . $report->id);
$mech->content_lacks('Cancel this booking');

set_fixed_time($good_date);
set_fixed_time($booking_date);
};

subtest "Can't view booking logged-out" => sub {
Expand Down Expand Up @@ -670,6 +672,20 @@ FixMyStreet::override_config {
};
};

# Note 12th August is still stubbed out as unavailable from above
subtest 'Booking too late' => sub {
set_fixed_time("2022-08-07T13:00:00Z");
$mech->get_ok('/waste/PE1%203NA:100090215480/bulky');
$mech->submit_form_ok;
$mech->submit_form_ok({ with_fields => { resident => 'Yes' } });
$mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email, phone => '44 07 111 111 111' }});
$mech->content_lacks('5 August');
$mech->content_lacks('12 August');
$mech->content_contains('19 August');
$mech->content_contains('26 August');
set_fixed_time($booking_date);
};

# Note 12th August is still stubbed out as unavailable from above
subtest 'Amending' => sub {

Expand Down Expand Up @@ -919,6 +935,7 @@ FixMyStreet::override_config {

# Still logged in as staff
my $report2;
set_fixed_time($booking_date);
subtest 'Make a second booking' => sub {
$mech->get_ok('/waste/PE1%203NA:100090215480');
$mech->follow_link_ok( { text_regex => qr/Book bulky goods collection/i, }, "follow 'Book bulky...' link" );
Expand Down

0 comments on commit 90b926b

Please sign in to comment.