Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/issues/freshdesk/2916-westminste…
Browse files Browse the repository at this point in the history
…r-tfl-message'
  • Loading branch information
chrismytton committed Sep 27, 2023
2 parents 7a25a36 + f7f580f commit 4585333
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 18 deletions.
10 changes: 10 additions & 0 deletions perllib/FixMyStreet/Cobrand/TfL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,16 @@ sub _cleaning_categories { [
'Graffiti',
'Litter or Weeds on a Street',
'Faulty Christmas Lights',
# Westminster additional categories by request
'Abandoned bike',
'Abandoned hire bicycles/e-scooters',
'Animal Nuisance',
'Busking and Street performance',
'Engine idling',
'Flytipping',
'Parks/landscapes',
'Street bin issue',
'Street cleaning',
] }

sub _cleaning_groups { [ 'Street cleaning', 'Street Cleansing', 'Fly-tipping', 'Street cleaning issues' ] }
Expand Down
11 changes: 4 additions & 7 deletions perllib/FixMyStreet/Cobrand/Westminster.pm
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,17 @@ sub _fetch_features_url {

sub categories_restriction {
my ($self, $rs) = @_;
# Westminster don't want TfL or email categories on their cobrand.
# Categories covering the council area have a mixture of Open311 and Email
# Westminster don't want email categories on their cobrand.
# Categories covering the body have a mixture of Open311 and Email
# send methods. We've set up the Email categories with a devolved
# send_method, so can identify Open311 categories as those which have a
# blank send_method.
# XXX This still shows "These will be sent to TfL or Westminster City Council"
# on /report/new before a category is selected...
# blank send_method; the TfL categories also all have a blank send method.
return $rs->search( {
'body.name' => 'Westminster City Council',
-or => [
'me.send_method' => undef, # Open311 categories
'me.send_method' => '', # Open311 categories that have been edited in the admin
]
}, { join => 'body' });
});
}

sub updates_restriction {
Expand Down
2 changes: 1 addition & 1 deletion t/cobrand/bucks.t
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ subtest 'Flytipping not on a road going to HE does not get recategorised' => sub
'road-placement' => 'off-road',
}
}, "submit details");
$mech->content_contains('We don’t handle this type of problem');
$mech->content_contains('From the information you have given, we have passed this report on to:');
my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first;
ok $report, "Found the report";
is $report->category, "Flytipping", 'Report was not recategorised';
Expand Down
34 changes: 25 additions & 9 deletions t/cobrand/westminster.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ use Test::MockModule;
use FixMyStreet::TestMech;
use FixMyStreet::Script::Reports;

use t::Mock::Tilma;
my $tilma = t::Mock::Tilma->new;
LWP::Protocol::PSGI->register($tilma->to_psgi_app, host => 'tilma.mysociety.org');

# disable info logs for this test run
FixMyStreet::App->log->disable('info');
END { FixMyStreet::App->log->enable('info'); }

ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' );
$mech->host('westminster.fixmystreet.com');

my $cobrand = Test::MockModule->new('FixMyStreet::Cobrand::Westminster');
$cobrand->mock('lookup_site_code', sub {
Expand All @@ -17,6 +22,12 @@ $cobrand->mock('lookup_site_code', sub {

my $body = $mech->create_body_ok(2504, 'Westminster City Council', {
send_method => 'Open311', api_key => 'key', 'endpoint' => 'e', 'jurisdiction' => 'j' }, { cobrand => 'westminster' });
my $tfl = $mech->create_body_ok(2504, 'TfL', {}, { cobrand => 'tfl' });
$mech->create_contact_ok(body_id => $body->id, category => 'Abandoned bike', email => "BIKE");
$mech->create_contact_ok(body_id => $body->id, category => 'Car parking', email => '[email protected]', send_method => 'Email');
$mech->create_contact_ok(body_id => $tfl->id, category => 'Pothole', email => '[email protected]');
$mech->create_contact_ok(body_id => $tfl->id, category => 'Traffic light', email => '[email protected]');

my $superuser = $mech->create_user_ok(
'[email protected]',
name => 'Test Superuser',
Expand All @@ -37,7 +48,7 @@ my $comment2 = $mech->create_comment_for_problem($report, $normal_user, 'User',
my $comment3 = $mech->create_comment_for_problem($report, $normal_user, 'User', 'this update was imported via Open311', 0, 'confirmed', 'confirmed', { cobrand => '' });

FixMyStreet::override_config {
ALLOWED_COBRANDS => 'westminster',
ALLOWED_COBRANDS => ['westminster', 'tfl'],
MAPIT_URL => 'http://mapit.uk/',
COBRAND_FEATURES => {
updates_allowed => {
Expand Down Expand Up @@ -83,6 +94,12 @@ FixMyStreet::override_config {
$mech->get_ok('/report/' . $report->id);
$mech->content_lacks($comment2->text);
};

subtest 'Correct categories are shown' => sub {
my $json = $mech->get_ok_json('/report/new/ajax?latitude=51.501009&longitude=-0.141588');
my @cats = sort keys %{$json->{by_category}};
is_deeply \@cats, ['Abandoned bike', 'Traffic light'];
};
};

subtest 'Reports have an update form for superusers' => sub {
Expand All @@ -91,7 +108,7 @@ subtest 'Reports have an update form for superusers' => sub {
$mech->log_in_ok( $superuser->email );

FixMyStreet::override_config {
ALLOWED_COBRANDS => 'westminster',
ALLOWED_COBRANDS => ['westminster', 'tfl'],
MAPIT_URL => 'http://mapit.uk/',
COBRAND_FEATURES => {
anonymous_account => { westminster => 'anon' },
Expand All @@ -110,7 +127,7 @@ subtest 'Reports have an update form for superusers' => sub {
subtest 'Reports have an update form for staff users' => sub {
$mech->log_in_ok( $staff_user->email );
FixMyStreet::override_config {
ALLOWED_COBRANDS => 'westminster',
ALLOWED_COBRANDS => ['westminster', 'tfl'],
MAPIT_URL => 'http://mapit.uk/',
COBRAND_FEATURES => {
updates_allowed => {
Expand All @@ -126,7 +143,7 @@ subtest 'Reports have an update form for staff users' => sub {

for (
{
ALLOWED_COBRANDS => 'westminster',
ALLOWED_COBRANDS => ['westminster', 'tfl'],
MAPIT_URL => 'http://mapit.uk/',
COBRAND_FEATURES => {
oidc_login => {
Expand All @@ -135,7 +152,7 @@ for (
}
},
{
ALLOWED_COBRANDS => 'westminster',
ALLOWED_COBRANDS => ['westminster', 'tfl'],
MAPIT_URL => 'http://mapit.uk/',
COBRAND_FEATURES => {
oidc_login => {
Expand All @@ -150,7 +167,7 @@ for (
}
},
{
ALLOWED_COBRANDS => 'westminster',
ALLOWED_COBRANDS => ['westminster', 'tfl'],
MAPIT_URL => 'http://mapit.uk/',
}
) {
Expand All @@ -168,14 +185,13 @@ for (
}

$mech->delete_problems_for_body($body->id);
$mech->create_contact_ok(body_id => $body->id, category => 'Abandoned bike', email => "BIKE");
($report) = $mech->create_problems_for_body(1, $body->id, 'Bike', {
category => "Abandoned bike", cobrand => 'westminster',
latitude => 51.501009, longitude => -0.141588, areas => '2504',
});

FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'westminster' ],
ALLOWED_COBRANDS => ['westminster', 'tfl'],
MAPIT_URL => 'http://mapit.uk/',
STAGING_FLAGS => { send_reports => 1, skip_checks => 0 },
COBRAND_FEATURES => { anonymous_account => { westminster => 'anon' } },
Expand All @@ -191,7 +207,7 @@ FixMyStreet::override_config {

for my $cobrand (qw(westminster fixmystreet)) {
FixMyStreet::override_config {
ALLOWED_COBRANDS => $cobrand,
ALLOWED_COBRANDS => [$cobrand, 'tfl'],
MAPIT_URL => 'http://mapit.uk/',
}, sub {
subtest "No reporter alert created in $cobrand" => sub {
Expand Down
2 changes: 1 addition & 1 deletion templates/web/base/tokens/confirm_problem.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h2>Your issue is on its way to the council.</h2>
[% ELSE %]
<h2>Thank you for your report.</h2>
<p>
We don&rsquo;t handle this type of problem, so have passed it on to:
From the information you have given, we have passed this report on to:
</p>
<p>
<b>[% report.body %]</b>
Expand Down

0 comments on commit 4585333

Please sign in to comment.