Skip to content

Commit

Permalink
[Bexley][WW] Fix street-wide status updates so they display on page
Browse files Browse the repository at this point in the history
We had been assigning the size of an array rather than an arrayref
to {service_updates}.
  • Loading branch information
nephila-nacrea authored and chrismytton committed Jun 3, 2024
1 parent a8d0c10 commit 78fabdd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
8 changes: 3 additions & 5 deletions perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ sub bin_services_for_address {
= $self->_in_cab_logs($property);
$property->{successful_collections} = $successful_collections;

Check warning on line 214 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L214

Added line #L214 was not covered by tests
$property->{red_tags} = $property_logs;
$property->{service_updates} = grep { $_->{service_update} } @$street_logs;
$property->{service_updates} = $street_logs;

Check warning on line 216 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L216

Added line #L216 was not covered by tests

# Set certain things outside of services loop
my $containers = $self->_containers($property);
Expand Down Expand Up @@ -543,10 +543,8 @@ sub _in_cab_logs {
date => $logdate,

Check warning on line 543 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L543

Added line #L543 was not covered by tests
ordinal => ordinal( $logdate->day ),
};
} else {
} elsif ( !$_->{Uprn} ) {
push @street_logs, {
# TODO This shouldn't be needed
service_update => $_->{Uprn} ? 0 : 1,
round => $_->{RoundCode},
reason => $_->{Reason},
date => $logdate,

Check warning on line 550 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L550

Added line #L550 was not covered by tests
Expand All @@ -566,7 +564,7 @@ sub can_report_missed {
return 0 if $property->{missed_collection_reports}{ $service->{service_id} };

# Prevent reporting if there are service updates
return 0 if $property->{service_updates};
return 0 if @{ $property->{service_updates} // [] };

# Prevent reporting if there are red tags on the service
# Red tags are matched to services based on prefix
Expand Down
37 changes: 30 additions & 7 deletions t/app/controller/waste_bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ FixMyStreet::override_config {
}
};

subtest 'Shows when a collection is due today' => sub {
subtest 'Various logs for today' => sub {
$whitespace_mock->mock( 'GetSiteCollections', sub {
return [
{ SiteServiceID => 8,
Expand All @@ -459,14 +459,17 @@ FixMyStreet::override_config {
$whitespace_mock->mock( 'GetInCabLogsByUsrn', sub { [] } );

set_fixed_time('2024-04-01T07:00:00'); # April 1st, 08:00 BST

note 'No in-cab logs';
$mech->get_ok('/waste/10001');
$mech->content_lacks('Service status');
$mech->content_contains('Being collected today');
$mech->content_lacks('Collection completed or attempted earlier today');

# Set time to later in the day
set_fixed_time('2024-04-01T16:01:00'); # April 1st, 17:01 BST

# Successful collection has occurred
note 'Successful collection has occurred';
$whitespace_mock->mock( 'GetInCabLogsByUsrn', sub {
return [
{
Expand All @@ -480,13 +483,11 @@ FixMyStreet::override_config {
];
});
$mech->get_ok('/waste/10001');
$mech->content_lacks(
'Our collection teams have reported the following problems with your bins:'
);
$mech->content_lacks('Service status');
$mech->content_lacks('Being collected today');
$mech->content_contains('Collection completed or attempted earlier today');

# Property has red tag on collection attempted earlier today
note 'Property has red tag on collection attempted earlier today';
$whitespace_mock->mock( 'GetInCabLogsByUprn', sub {
return [
{
Expand All @@ -501,13 +502,14 @@ FixMyStreet::override_config {
});
$whitespace_mock->mock( 'GetInCabLogsByUsrn', sub { [] } );
$mech->get_ok('/waste/10001');
$mech->content_contains('Service status');
$mech->content_contains(
'Our collection teams have reported the following problems with your bins:'
);
$mech->content_lacks('Being collected today');
$mech->content_contains('Collection completed or attempted earlier today');

# Red tag on other property on same street
note 'Red tag on other property on same street';
$whitespace_mock->mock( 'GetInCabLogsByUprn', sub { [] } );
$whitespace_mock->mock( 'GetInCabLogsByUsrn', sub {
return [
Expand All @@ -522,6 +524,27 @@ FixMyStreet::override_config {
];
});
$mech->get_ok('/waste/10001');
$mech->content_lacks('Service status');
$mech->content_lacks('Being collected today');
$mech->content_contains('Collection completed or attempted earlier today');

note 'Service update on street';
$whitespace_mock->mock( 'GetInCabLogsByUprn', sub { [] } );
$whitespace_mock->mock( 'GetInCabLogsByUsrn', sub {
return [
{
LogID => 1,
Reason => 'Streetwide fox invasion',
RoundCode => 'RND-8-9',
LogDate => '2024-04-01T12:00:00.417',
Uprn => '',
Usrn => '321',
},
];
});
$mech->get_ok('/waste/10001');
$mech->content_contains('Service status');
$mech->content_contains('Streetwide fox invasion');
$mech->content_lacks(
'Our collection teams have reported the following problems with your bins:'
);
Expand Down

0 comments on commit 78fabdd

Please sign in to comment.