Skip to content

Commit

Permalink
[Kingston] Remove new bin options from replace flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Apr 8, 2024
1 parent 00a3758 commit 47bdef4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 95 deletions.
19 changes: 3 additions & 16 deletions perllib/FixMyStreet/App/Form/Waste/Request/Kingston.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use utf8;
use HTML::FormHandler::Moose;
extends 'FixMyStreet::App::Form::Waste::Request';

use constant CONTAINER_RECYCLING_BIN => 12;
use constant CONTAINER_RECYCLING_BOX => 16;

=head2 About you
Expand Down Expand Up @@ -85,8 +84,8 @@ has_field how_many => (

=head2 Reason for replacement
The user is asked why they need a new container - damaged, missing, new
resident (unless a garden bin) or they require more (if they have a green box).
The user is asked why they need a new container - damaged, missing,
or they require more (if they have a green box).
=cut

Expand Down Expand Up @@ -115,16 +114,12 @@ sub options_request_reason {
my $form = shift;
my $data = $form->saved_data;
my $choice = $data->{'container-choice'} || 0;
my $garden = $data->{'container-26'} || $data->{'container-27'} || $choice == 26 || $choice == 27;
my $green_box = $data->{'container-' . CONTAINER_RECYCLING_BOX} || $choice == CONTAINER_RECYCLING_BOX;
my $green_bin = ($data->{'container-' . CONTAINER_RECYCLING_BIN} || $choice == CONTAINER_RECYCLING_BIN) && !$form->{c}->stash->{container_recycling_bin} && $data->{recycling_swap} ne 'No';
my @options;
push @options, { value => 'new_build', label => 'I am a new resident without a container' }
if !$garden;
push @options, { value => 'damaged', label => 'My container is damaged' };
push @options, { value => 'missing', label => 'My container is missing' };
push @options, { value => 'more', label => 'I need an additional container/bin' }
if $green_box || $green_bin;
if $green_box;
return @options;
}

Expand All @@ -138,17 +133,9 @@ for a bin, the user is asked if they'd like to swap their boxes for a bin.
has_page recycling_swap => (
fields => ['recycling_swap', 'continue'],
title => 'Reason for request',
update_field_list => sub {
my $form = shift;
my $c = $form->{c};
my $data = $form->saved_data;
$data->{_container_recycling_bin} = $c->stash->{container_recycling_bin};
return {};
},
next => sub {
my $data = shift;
return 'recycling_swap_confirm' if $data->{recycling_swap} eq 'Yes';
return 'replacement' if $data->{"container-choice"} == CONTAINER_RECYCLING_BIN && !$data->{_container_recycling_bin};
return 'about_you';
},
);
Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/Cobrand/Kingston.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ sub image_for_unit {

# Base mixed recycling (2241) on the container itself
my %containers = map { $_ => 1 } @{$unit->{request_containers}};
return "$base/bin-green" if $containers{+CONTAINER_RECYCLING_BIN} && $self->{c}->stash->{container_recycling_bin};
return "$base/bin-green" if $containers{+CONTAINER_RECYCLING_BIN};
return "$base/box-green-mix" if $containers{+CONTAINER_RECYCLING_BOX};

my $service_id = $unit->{service_id};
Expand Down
11 changes: 0 additions & 11 deletions perllib/FixMyStreet/Roles/CobrandSLWP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,6 @@ sub bin_services_for_address {
next if $container == CONTAINER_REFUSE_RED_BAG;
next if $container == CONTAINER_RECYCLING_BLUE_BAG && $schedules->{description} !~ /fortnight/; # Blue stripe bag on a weekly collection
if ($container && $quantity) {
# Store this fact here for use in new request flow
$self->{c}->stash->{container_recycling_bin} = 1 if $container == CONTAINER_RECYCLING_BIN;
push @$containers, $container;
next if $container == CONTAINER_GARDEN_SACK;
# The most you can request - ignored on replacements anyway
Expand Down Expand Up @@ -563,11 +561,6 @@ sub bin_services_for_address {
push @$containers, CONTAINER_FOOD_INDOOR; # Food waste bin (kitchen)
$request_max->{+CONTAINER_FOOD_INDOOR} = 1;
}
if ($self->moniker eq 'kingston' && grep { $_ == CONTAINER_RECYCLING_BOX } @$containers) {
# Can request a bin if you have a box
push @$containers, CONTAINER_RECYCLING_BIN;
$request_max->{+CONTAINER_RECYCLING_BIN} = 1;
}

my $open_requests = { map { $_ => $events->{request}->{$_} } grep { $events->{request}->{$_} } @$containers };
if ($self->moniker eq 'sutton') {
Expand Down Expand Up @@ -913,10 +906,6 @@ sub waste_request_form_first_next {
return 'about_you';

Check warning on line 906 in perllib/FixMyStreet/Roles/CobrandSLWP.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Roles/CobrandSLWP.pm#L906

Added line #L906 was not covered by tests
}
return 'about_you' if $choice == CONTAINER_RECYCLING_BLUE_BAG || $choice == CONTAINER_PAPER_SINGLE_BAG;
if ($cls eq 'Kingston' && $choice == CONTAINER_RECYCLING_BIN && !$self->{c}->stash->{container_recycling_bin}) {
$data->{request_reason} = 'more';
return 'recycling_swap';
}
if ($cls eq 'Sutton') {
foreach (CONTAINER_REFUSE_140, CONTAINER_REFUSE_240, CONTAINER_PAPER_BIN) {
if ($choice == $_ && !$containers->{$_}) {
Expand Down
67 changes: 0 additions & 67 deletions t/app/controller/waste_kingston_r.t
Original file line number Diff line number Diff line change
Expand Up @@ -168,28 +168,6 @@ FixMyStreet::override_config {
is $cgi->param('attribute[Action]'), '1';
is $cgi->param('attribute[Reason]'), '1';
};
subtest 'Request new build container' => sub {
$mech->get_ok('/waste/12345/request');
$mech->submit_form_ok({ with_fields => { 'container-choice' => 1 } });
$mech->submit_form_ok({ with_fields => { 'how_many' => 'less5' }});
$mech->submit_form_ok({ with_fields => { 'request_reason' => 'new_build' }});
$mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }});
$mech->waste_submit_check({ with_fields => { process => 'summary' } });
is $sent_params->{items}[0]{amount}, 1800;

my ( $token, $report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} );
$mech->get_ok("/waste/pay_complete/$report_id/$token");
$mech->content_contains('request has been sent');
is $report->get_extra_field_value('uprn'), 1000000002;
is $report->detail, "Quantity: 1\n\n2 Example Street, Kingston, KT1 1AA\n\nReason: I am a new resident without a container";
is $report->title, 'Request new Black rubbish bin';
FixMyStreet::Script::Reports::send();
my $req = Open311->test_req_used;
my $cgi = CGI::Simple->new($req->content);
is $cgi->param('attribute[Action]'), '1';
is $cgi->param('attribute[Reason]'), '4';
is $cgi->param('attribute[Container_Type]'), '35';
};
subtest 'Request a new damaged recycling box' => sub {
$mech->get_ok('/waste/12345/request');
$mech->submit_form_ok({ with_fields => { 'container-choice' => 16 } });
Expand Down Expand Up @@ -255,50 +233,6 @@ FixMyStreet::override_config {
is $cgi->param('attribute[Action]'), '2::2::2::1';
is $cgi->param('attribute[Reason]'), '3::3::3::3';
};
subtest 'Request recycling boxes bin swap, second way' => sub {
$mech->get_ok('/waste/12345/request');
$mech->submit_form_ok({ with_fields => { 'container-choice' => 12 } });
$mech->submit_form_ok({ with_fields => { 'recycling_swap' => 'Yes' }});
$mech->submit_form_ok({ with_fields => { 'recycling_swap_confirm' => 1 }});
$mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }});
$mech->waste_submit_check({ with_fields => { process => 'summary' } });
is $sent_params->{items}[0]{amount}, 1800;

my ( $token, $report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} );
$mech->get_ok("/waste/pay_complete/$report_id/$token");
$mech->content_contains('request has been sent');
is $report->get_extra_field_value('uprn'), 1000000002;
is $report->detail, "Quantity: 1\n\n2 Example Street, Kingston, KT1 1AA\n\nReason: I need an additional container/bin";
is $report->title, 'Request new Green recycling bin (240L)';
FixMyStreet::Script::Reports::send();
my $req = Open311->test_req_used;
my $cgi = CGI::Simple->new($req->content);
is $cgi->param('attribute[Container_Type]'), '16::16::16::12';
is $cgi->param('attribute[Action]'), '2::2::2::1';
is $cgi->param('attribute[Reason]'), '3::3::3::3';
};
subtest 'Request recycling boxes bin swap, change mind' => sub {
$mech->get_ok('/waste/12345/request');
$mech->submit_form_ok({ with_fields => { 'container-choice' => 12 } });
$mech->submit_form_ok({ with_fields => { 'recycling_swap' => 'No' }});
$mech->submit_form_ok({ with_fields => { 'request_reason' => 'new_build' }});
$mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }});
$mech->waste_submit_check({ with_fields => { process => 'summary' } });
is $sent_params->{items}[0]{amount}, 1800;

my ( $token, $report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} );
$mech->get_ok("/waste/pay_complete/$report_id/$token");
$mech->content_contains('request has been sent');
is $report->get_extra_field_value('uprn'), 1000000002;
is $report->detail, "Quantity: 1\n\n2 Example Street, Kingston, KT1 1AA\n\nReason: I am a new resident without a container";
is $report->title, 'Request new Green recycling bin (240L)';
FixMyStreet::Script::Reports::send();
my $req = Open311->test_req_used;
my $cgi = CGI::Simple->new($req->content);
is $cgi->param('attribute[Container_Type]'), '12';
is $cgi->param('attribute[Action]'), '1';
is $cgi->param('attribute[Reason]'), '4';
};
subtest 'Request recycling bin replacement, no additional' => sub {
my $clone = dclone($bin_data);
# Change 16/3 to 12/1
Expand Down Expand Up @@ -436,7 +370,6 @@ FixMyStreet::override_config {
$mech->content_contains('Report a mixed recycling collection as missed');
$mech->get_ok('/waste/12345/request');
$mech->content_like(qr/name="container-choice" value="16"[^>]+disabled/s); # green
$mech->content_like(qr/name="container-choice" value="12"[^>]+disabled/s); # green

$e->mock('GetEventsForObject', sub { [ {
# Request
Expand Down

0 comments on commit 47bdef4

Please sign in to comment.