Skip to content

Commit

Permalink
[SLWP] Staff must provide email also.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Aug 16, 2023
1 parent d1f9eac commit 8a440ea
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
3 changes: 2 additions & 1 deletion perllib/FixMyStreet/App/Form/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ sub validate {
my $c = $self->c;
my $cobrand = $c->cobrand->moniker;
my $is_staff_user = ($c->user_exists && ($c->user->from_body || $c->user->is_superuser));
my $staff_provide_email = $c->cobrand->moniker eq 'kingston' || $c->cobrand->moniker eq 'sutton';

$self->add_form_error('Please provide an email address')
unless $email->is_inactive || $email->value || $is_staff_user;
unless $email->is_inactive || $email->value || ($is_staff_user && !$staff_provide_email);

$self->add_form_error('Please provide email and/or phone')
unless $phone->is_inactive || $phone->value || $email->value || ($is_staff_user && $cobrand eq 'bromley');
Expand Down
54 changes: 24 additions & 30 deletions t/app/controller/waste_kingston.t
Original file line number Diff line number Diff line change
Expand Up @@ -1406,40 +1406,34 @@ FixMyStreet::override_config {
$echo->mock('GetServiceUnitsForObject', \&garden_waste_one_bin);

subtest 'check staff renewal' => sub {
foreach ({ email => '[email protected]' }, { phone => '07700900002' }) {
$mech->log_out_ok;
$mech->log_in_ok($staff_user->email);
$mech->get_ok('/waste/12345/garden_renew');
$mech->submit_form_ok({ with_fields => {
name => 'a user',
%$_, # email or phone,
current_bins => 1,
bins_wanted => 1,
payment_method => 'credit_card',
}});
$mech->content_contains('20.00');

$mech->submit_form_ok({ with_fields => { tandc => 1 } });
is $call_params->{'scpbase:panEntryMethod'}, 'CNP', 'Correct cardholder-not-present flag';
is $call_params->{'scpbase:billing'}{'scpbase:cardHolderDetails'}{'scpbase:cardHolderName'}, 'a user', 'Correct name';
if ($_->{email}) {
is $call_params->{'scpbase:billing'}{'scpbase:cardHolderDetails'}{'scpbase:contact'}{'scpbase:email'}, $_->{email}, 'Correct email';
} else {
is $call_params->{'scpbase:billing'}{'scpbase:cardHolderDetails'}{'scpbase:contact'}, undef, 'No email section';
}
is $sent_params->{items}[0]{amount}, 2000, 'correct amount used';
is $sent_params->{items}[1]{amount}, undef, 'correct amount used';
$mech->log_out_ok;
$mech->log_in_ok($staff_user->email);
$mech->get_ok('/waste/12345/garden_renew');
$mech->submit_form_ok({ with_fields => {
name => 'a user',
email => '[email protected]',
current_bins => 1,
bins_wanted => 1,
payment_method => 'credit_card',
}});
$mech->content_contains('20.00');

my ( $token, $report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} );
$mech->submit_form_ok({ with_fields => { tandc => 1 } });
is $call_params->{'scpbase:panEntryMethod'}, 'CNP', 'Correct cardholder-not-present flag';
is $call_params->{'scpbase:billing'}{'scpbase:cardHolderDetails'}{'scpbase:cardHolderName'}, 'a user', 'Correct name';
is $call_params->{'scpbase:billing'}{'scpbase:cardHolderDetails'}{'scpbase:contact'}{'scpbase:email'}, '[email protected]', 'Correct email';
is $sent_params->{items}[0]{amount}, 2000, 'correct amount used';
is $sent_params->{items}[1]{amount}, undef, 'correct amount used';

check_extra_data_pre_confirm($report, type => 'Renew', new_bins => 0);
my ( $token, $report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} );

$mech->get_ok("/waste/pay_complete/$report_id/$token");
is $sent_params->{scpReference}, 12345, 'correct scpReference sent';
check_extra_data_pre_confirm($report, type => 'Renew', new_bins => 0);

check_extra_data_post_confirm($report);
$report->delete; # Otherwise next test sees this as latest
}
$mech->get_ok("/waste/pay_complete/$report_id/$token");
is $sent_params->{scpReference}, 12345, 'correct scpReference sent';

check_extra_data_post_confirm($report);
$report->delete; # Otherwise next test sees this as latest
};

subtest 'check staff renewal with direct debit' => sub {
Expand Down
8 changes: 6 additions & 2 deletions t/app/controller/waste_sutton_garden.t
Original file line number Diff line number Diff line change
Expand Up @@ -1088,9 +1088,9 @@ FixMyStreet::override_config {
$echo->mock('GetServiceUnitsForObject', \&garden_waste_one_bin);

subtest 'check staff renewal' => sub {
$mech->log_out_ok;
$mech->log_in_ok($staff_user->email);
foreach ({ email => '[email protected]' }, { phone => '07700900002' }) {
$mech->log_out_ok;
$mech->log_in_ok($staff_user->email);
$mech->get_ok('/waste/12345/garden_renew');
$mech->submit_form_ok({ with_fields => {
name => 'a user',
Expand All @@ -1099,6 +1099,10 @@ FixMyStreet::override_config {
bins_wanted => 1,
payment_method => 'credit_card',
}});
if (!$_->{email}) {
$mech->content_contains("Please provide an email");
next;
}
$mech->content_contains('20.00');

$mech->submit_form_ok({ with_fields => { tandc => 1 } });
Expand Down

0 comments on commit 8a440ea

Please sign in to comment.