Skip to content

Commit

Permalink
[TfL] Allow through TfL as a name if reporting as staff.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Jun 7, 2024
1 parent acf3c69 commit a203eba
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
14 changes: 14 additions & 0 deletions perllib/FixMyStreet/Cobrand/TfL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,20 @@ sub report_new_munge_before_insert {
$report->set_extra_fields(@$extra);
}

=head2 report_validation
Allow through "TfL" as a name if reporting as staff.
=cut

sub report_validation {
my ($self, $report, $errors) = @_;

if ($errors->{name} && $report->name eq 'TfL' && $report->user->from_body) {
delete $errors->{name};
}
}

sub report_new_is_on_tlrn {
my ( $self ) = @_;

Expand Down
24 changes: 24 additions & 0 deletions t/cobrand/tfl.t
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,30 @@ subtest "test report creation anonymously by staff user" => sub {
$mech->log_out_ok;
};

subtest "test report creation as body by staff user" => sub {
$mech->log_in_ok( $staffuser->email );
$mech->get_ok('/around');
$mech->submit_form_ok( { with_fields => { pc => 'BR1 3UH', } }, "submit location" );
$mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" );
$mech->submit_form_ok({ with_fields => {
title => 'Test Report 3',
detail => 'Test report details.',
category => 'Bus stops',
} }, "submit report");
is_deeply $mech->page_errors, [], "check there were no errors";

my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 3'});
ok $report, "Found the report";
is $report->name, 'TfL';
is $report->user->email, $staffuser->email;
is $report->anonymous, 0;
is $report->get_extra_metadata('contributed_as'), 'body';

$mech->content_contains('Your issue is on its way to Transport for London');
$mech->content_contains('Your reference for this report is FMS' . $report->id);
$mech->log_out_ok;
};

FixMyStreet::DB->resultset("Problem")->delete_all;

my $tfl_staff = FixMyStreet::DB->resultset("User")->find({ email => '[email protected]'});
Expand Down

0 comments on commit a203eba

Please sign in to comment.