diff --git a/perllib/FixMyStreet/Cobrand/Brent.pm b/perllib/FixMyStreet/Cobrand/Brent.pm
index efcfa90ae42..08c2a63a5eb 100644
--- a/perllib/FixMyStreet/Cobrand/Brent.pm
+++ b/perllib/FixMyStreet/Cobrand/Brent.pm
@@ -24,6 +24,7 @@ use DateTime::Format::Strptime;
use Try::Tiny;
use LWP::Simple;
use URI;
+use JSON::MaybeXS;
=head1 INTEGRATIONS
@@ -46,7 +47,8 @@ with 'FixMyStreet::Roles::CobrandEcho';
with 'FixMyStreet::Roles::SCP';
use Integrations::Paye;
-sub council_area_id { return 2488; }
+# Brent covers some of the areas around it so that it can handle near-boundary reports
+sub council_area_id { return [2488, 2505, 2489, 2487]; } # 2505 Camden, 2489 Barnet, 2487 Harrow
sub council_area { return 'Brent'; }
sub council_name { return 'Brent Council'; }
sub council_url { return 'brent'; }
@@ -135,6 +137,8 @@ sub disambiguate_location { {
=item * Filters down search results to be the street name and the postcode only
+=back
+
=cut
sub geocoder_munge_results {
@@ -143,7 +147,140 @@ sub geocoder_munge_results {
$result->{display_name} =~ s/, London Borough of Brent, London, Greater London, England//;
}
-=back
+=head2 check_report_is_on_cobrand_asset
+
+If the location is covered by an area of differing responsibility (e.g. Brent
+in Camden, or Camden in Brent), return true (either 1 if an area name is
+provided, or the name of the area if not).
+
+=cut
+
+sub check_report_is_on_cobrand_asset {
+ my ($self, $council_area) = shift @_;
+
+ my $lat = $self->{c}->stash->{latitude};
+ my $lon = $self->{c}->stash->{longitude};
+ my $host = FixMyStreet->config('STAGING_SITE') ? "tilma.staging.mysociety.org" : "tilma.mysociety.org";
+
+ my $cfg = {
+ url => "https://$host/mapserver/brent",
+ srsname => "urn:ogc:def:crs:EPSG::4326",
+ typename => "BrentDiffs",
+ filter => "Geometry$lon,$lat",
+ outputformat => 'GML3',
+ };
+
+ my $features = $self->_fetch_features($cfg, -1, -1, 1);
+
+ if ($$features[0]) {
+ if ($council_area) {
+ if ($$features[0]->{'ms:BrentDiffs'}->{'ms:name'} eq $council_area) {
+ return 1;
+ }
+ } else {
+ return $$features[0]->{'ms:BrentDiffs'}->{'ms:name'};
+ }
+ }
+}
+
+=head2 munge_overlapping_asset_bodies
+
+Alters the list of available bodies for the location,
+depending on calculated responsibility. After this function,
+the bodies list will be the relevant bodies for the point,
+though categories may need to be altered later on.
+
+=cut
+
+sub munge_overlapping_asset_bodies {
+ my ($self, $bodies) = @_;
+
+ # in_area will be true if the point is within the administrative area of Brent
+ my $in_area = grep ($self->council_area_id->[0] == $_, keys %{$self->{c}->stash->{all_areas}});
+ # cobrand will be true if the point is within an area of different responsibility from the norm
+ my $cobrand = $self->check_report_is_on_cobrand_asset;
+
+ if ($in_area) {
+ # In the area of Brent...
+ if (!$cobrand || $cobrand eq 'Brent') {
+ # ...Brent's responsibility - remove the other bodies covering the Brent area
+ %$bodies = map { $_->id => $_ } grep {
+ $_->name ne 'Camden Borough Council' &&
+ $_->name ne 'Barnet Borough Council' &&
+ $_->name ne 'Harrow Borough Council'
+ } values %$bodies;
+ } else {
+ # ...someone else's responsibility, take out the ones definitely not responsible
+ my %cobrands = (Harrow => 'Harrow Borough Council', Camden => 'Camden Borough Council', Barnet => 'Barnet Borough Council');
+ my $selected = $cobrands{$cobrand};
+ %$bodies = map { $_->id => $_ } grep {
+ $_->name eq $selected || $_->name eq 'Brent Council' || $_->name eq 'TfL' || $_->name eq 'National Highways'
+ } values %$bodies;
+ }
+ } else {
+ # Not in the area of Brent...
+ if (!$cobrand || $cobrand ne 'Brent') {
+ # ...not Brent's responsibility - remove Brent
+ %$bodies = map { $_->id => $_ } grep {
+ $_->name ne 'Brent Council'
+ } values %$bodies;
+ } else {
+ # ...Brent's responsibility - leave (both) bodies alone
+ }
+ }
+}
+
+=head2 munge_cobrand_asset_categories
+
+If we're in an overlapping area, we want to take the street categories
+of one body, and the non-street categories of the other.
+
+=cut
+
+sub munge_cobrand_asset_categories {
+ my ($self, $contacts) = @_;
+
+ my %bodies = map { $_->body->name => $_->body } @$contacts;
+ my %non_street = (
+ 'Barnet' => { map { $_ => 1 } @{ $self->_barnet_non_street } },
+ 'Camden' => { map { $_ => 1 } @{ $self->_camden_non_street } },
+ 'Harrow' => { map { $_ => 1 } @{ $self->_harrow_non_street } },
+ );
+
+ # in_area will be true if the point is within the administrative area of Brent
+ my $in_area = grep ($self->council_area_id->[0] == $_, keys %{$self->{c}->stash->{all_areas}});
+ # cobrand will be true if the point is within an area of different responsibility from the norm
+ my $cobrand = $self->check_report_is_on_cobrand_asset || '';
+ return unless $cobrand;
+
+ my $brent_body = $self->body->id;
+ if (!$in_area && $cobrand eq 'Brent') {
+ # Outside the area of Brent, but Brent's responsibility
+ my $area;
+ if (grep {$_->{name} eq 'Camden Borough Council'} values %{$self->{c}->stash->{all_areas}}){
+ $area = 'Camden';
+ } elsif (grep {$_->{name} eq 'Harrow Borough Council'} values %{$self->{c}->stash->{all_areas}}) {
+ $area = 'Harrow';
+ } elsif (grep {$_->{name} eq 'Barnet Borough Council'} values %{$self->{c}->stash->{all_areas}}) {
+ $area = 'Barnet';
+ };
+ my $other_body = $bodies{$area . " Borough Council"};
+
+ # Remove the non-street contacts of Brent
+ @$contacts = grep { !($_->email !~ /^Symology/ && $_->body_id == $brent_body) } @$contacts;
+ # Remove the street contacts of the other
+ @$contacts = grep { !(!$non_street{$area}{$_->category} && $_->body_id == $other_body->id) } @$contacts
+ if $other_body;
+ } elsif ($in_area && $cobrand ne 'Brent') {
+ # Inside the area of Brent, but not Brent's responsibility
+ my $other_body = $bodies{$cobrand . " Borough Council"};
+ # Remove the street contacts of Brent
+ @$contacts = grep { !($_->email =~ /^Symology/ && $_->body_id == $brent_body) } @$contacts;
+ # Remove the non-street contacts of the other
+ @$contacts = grep { !($non_street{$cobrand}{$_->category} && $_->body_id == $other_body->id) } @$contacts
+ if $other_body;
+ }
+}
=head2 pin_colour
@@ -1544,7 +1681,6 @@ sub waste_get_pro_rata_cost {
return $self->feature('payment_gateway')->{ggw_cost};
}
-
sub bulky_collection_time { { hours => 7, minutes => 0 } }
sub bulky_cancellation_cutoff_time { { hours => 23, minutes => 59 } }
sub bulky_cancel_by_update { 1 }
@@ -1637,4 +1773,35 @@ sub waste_reconstruct_bulky_data {
return $saved_data;
}
+sub _barnet_non_street {
+ return [
+ 'Abandoned vehicles',
+ 'Graffiti',
+ 'Dog fouling',
+ 'Overhanging foliage',
+ ]
+};
+
+sub _camden_non_street {
+ return [
+ 'Abandoned Vehicles',
+ 'Dead animal',
+ 'Flyposting',
+ 'Public toilets',
+ 'Recycling & rubbish (Missed bin)',
+ 'Dott e-bike / e-scooter',
+ 'Human Forest e-bike',
+ 'Lime e-bike / e-scooter',
+ 'Tier e-bike / e-scooter',
+ ]
+}
+
+sub _harrow_non_street {
+ return [
+ 'Abandoned vehicles',
+ 'Car parking',
+ 'Graffiti',
+ ]
+}
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/Camden.pm b/perllib/FixMyStreet/Cobrand/Camden.pm
index c1e144f2b29..34611f40783 100644
--- a/perllib/FixMyStreet/Cobrand/Camden.pm
+++ b/perllib/FixMyStreet/Cobrand/Camden.pm
@@ -15,7 +15,7 @@ use parent 'FixMyStreet::Cobrand::Whitelabel';
use strict;
use warnings;
-sub council_area_id { return 2505; }
+sub council_area_id { return [2505, 2488]; }
sub council_area { return 'Camden'; }
sub council_name { return 'Camden Council'; }
sub council_url { return 'camden'; }
@@ -131,6 +131,103 @@ sub user_from_oidc {
return ($name, $email);
}
+=head2 check_report_is_on_cobrand_asset
+
+If the location is covered by an area of differing responsibility (e.g. Brent
+in Camden, or Camden in Brent), return true (either 1 if an area name is
+provided, or the name of the area if not). Identical to function in Brent.pm
+
+=cut
+
+sub check_report_is_on_cobrand_asset {
+ my ($self, $council_area) = shift @_;
+
+ my $lat = $self->{c}->stash->{latitude};
+ my $lon = $self->{c}->stash->{longitude};
+ my ($x, $y) = Utils::convert_latlon_to_en($lat, $lon, 'G');
+ my $host = FixMyStreet->config('STAGING_SITE') ? "tilma.staging.mysociety.org" : "tilma.mysociety.org";
+
+ my $cfg = {
+ url => "https://$host/mapserver/brent",
+ srsname => "urn:ogc:def:crs:EPSG::27700",
+ typename => "BrentDiffs",
+ filter => "Geometry$x,$y",
+ outputformat => 'GML3',
+ };
+
+ my $features = $self->_fetch_features($cfg, $x, $y, 1);
+
+ if ($$features[0]) {
+ if ($council_area) {
+ if ($$features[0]->{'ms:BrentDiffs'}->{'ms:name'} eq $council_area) {
+ return 1;
+ }
+ } else {
+ return $$features[0]->{'ms:BrentDiffs'}->{'ms:name'};
+ }
+ }
+}
+
+=head2 munge_overlapping_asset_bodies
+
+Alters the list of available bodies for the location,
+depending on calculated responsibility. Here, we remove the
+Brent body if we're inside Camden and it's not a Brent area.
+
+=cut
+
+sub munge_overlapping_asset_bodies {
+ my ($self, $bodies) = @_;
+
+ # in_area will be true if the point is within the administrative area of Camden
+ my $in_area = scalar(%{$self->{c}->stash->{all_areas}}) == 1 && (values %{$self->{c}->stash->{all_areas}})[0]->{id} eq $self->council_area_id->[0];
+ # cobrand will be true if the point is within an area of different responsibility from the norm
+ my $cobrand = $self->check_report_is_on_cobrand_asset;
+ if ($in_area && !$cobrand) {
+ # Within Camden, and Camden's responsibility
+ %$bodies = map { $_->id => $_ } grep {
+ $_->name ne 'Brent Council'
+ } values %$bodies;
+ }
+};
+
+=head2 munge_cobrand_asset_categories
+
+If we're in an overlapping area, we want to take the street categories
+of one body, and the non-street categories of the other.
+
+=cut
+
+sub munge_cobrand_asset_categories {
+ my ($self, $contacts) = @_;
+
+ # in_area will be true if the point is within the administrative area of Camden
+ my $in_area = scalar(%{$self->{c}->stash->{all_areas}}) == 1 && (values %{$self->{c}->stash->{all_areas}})[0]->{id} eq $self->council_area_id->[0];
+ # cobrand will be true if the point is within an area of different responsibility from the norm
+ my $cobrand = $self->check_report_is_on_cobrand_asset || '';
+
+ my $brent = FixMyStreet::Cobrand::Brent->new();
+ my %non_street = map { $_ => 1 } @{ $brent->_camden_non_street } ;
+ my $brent_body = $brent->body;
+ my $camden_body = $self->body;
+
+ if ($in_area && $cobrand eq 'Brent') {
+ # Within Camden, but Brent's responsibility
+ # Remove the non-street contacts of Brent
+ @$contacts = grep { !($_->email !~ /^Symology/ && $_->body_id == $brent_body->id) } @$contacts
+ if $brent_body;
+ # Remove the street contacts of Camden
+ @$contacts = grep { !(!$non_street{$_->category} && $_->body_id == $camden_body->id) } @$contacts;
+ } elsif (!$in_area && $cobrand eq 'Camden') {
+ # Outside Camden, but Camden's responsibility
+ # Remove the street contacts of Brent
+ @$contacts = grep { !($_->email =~ /^Symology/ && $_->body_id == $brent_body->id) } @$contacts
+ if $brent_body;
+ # Remove the non-street contacts of Camden
+ @$contacts = grep { !($non_street{$_->category} && $_->body_id == $camden_body->id) } @$contacts;
+ }
+}
+
=head2 dashboard_export_problems_add_columns
Has user name and email fields added to their csv export
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index 0b7a480e6b6..222254027af 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -204,6 +204,11 @@ sub munge_report_new_bodies {
my $bristol = FixMyStreet::Cobrand::Bristol->new({ c => $self->{c} });
$bristol->munge_overlapping_asset_bodies($bodies);
}
+
+ if ( $bodies{'Brent Council'} ) {
+ my $brent = FixMyStreet::Cobrand::Brent->new({ c => $self->{c} });
+ $brent->munge_overlapping_asset_bodies($bodies);
+ }
}
sub munge_report_new_contacts {
@@ -238,6 +243,11 @@ sub munge_report_new_contacts {
my $nh = FixMyStreet::Cobrand::HighwaysEngland->new({ c => $self->{c} });
$nh->national_highways_cleaning_groups($contacts);
}
+
+ if ( $bodies{'Brent Council'} ) {
+ my $brent = FixMyStreet::Cobrand::Brent->new({ c => $self->{c} });
+ $brent->munge_cobrand_asset_categories($contacts);
+ }
}
sub munge_unmixed_category_groups {
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index f09c716970f..eb5297ec662 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -193,10 +193,8 @@ sub responsible_for_areas {
# This will need changing for two tier councils
if (grep ($self->council_area_id->[0] == $_, keys %$councils)) {
return 1;
- } elsif ($self->check_report_is_on_cobrand_asset) {
- return 1;
} else {
- return 0;
+ return $self->check_report_is_on_cobrand_asset($self->council_area);
}
} else {
# The majority of cobrands only cover a single area, but e.g. Northamptonshire
@@ -416,10 +414,7 @@ sub munge_report_new_bodies {
$thamesmead->munge_thamesmead_body($bodies);
}
- if ( $bodies{'Bristol City Council'} ) {
- my $bristol = FixMyStreet::Cobrand::Bristol->new({ c => $self->{c} });
- $bristol->munge_overlapping_asset_bodies($bodies);
- }
+ $self->call_hook(munge_overlapping_asset_bodies => $bodies);
}
sub munge_report_new_contacts {
@@ -457,6 +452,9 @@ sub munge_report_new_contacts {
my $nh = FixMyStreet::Cobrand::HighwaysEngland->new({ c => $self->{c} });
$nh->national_highways_cleaning_groups($contacts);
}
+
+ $self->call_hook(munge_cobrand_asset_categories => $contacts);
+
}
=item wasteworks_config
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index c028394bf4d..366ea638886 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -112,6 +112,7 @@ my @PLACES = (
[ 'CA12 5FJ', 54.60102, -3.13648, 2274, 'Allerdale Borough Council', 'DIS' ],
[ 'NE61 1BE', 55.169081, -1.691012, 2248, 'Northumberland County Council', 'UTA' ],
[ 'SG17 5TQ', 52.03553, -0.36067, 21070, 'Central Bedfordshire Council', 'UTA' ],
+ [ '?', 51.558568, -0.207702, 2489, 'Barnet Borough Council', 'DIS' ],
);
sub dispatch_request {
diff --git a/t/app/controller/auth_social.t b/t/app/controller/auth_social.t
index f86d84b5880..ca79f7aa4d4 100644
--- a/t/app/controller/auth_social.t
+++ b/t/app/controller/auth_social.t
@@ -227,6 +227,11 @@ FixMyStreet::override_config $test->{config}, sub {
$resolver->mock('address', sub { $test->{email} });
+# Bodies need to exist for Brent::Cobrand::munge_cobrand_asset_categories searching ids
+$mech->create_body_ok(2505, 'Camden Borough Council', {},{cobrand => 'camden'});
+$mech->create_body_ok(2489, 'Barnet Borough Council');
+$mech->create_body_ok(2487, 'Harrow Borough Council');
+
for my $state ( 'refused', 'no email', 'existing UID', 'okay' ) {
for my $page ( 'my', 'report', 'update' ) {
next if $page eq 'update' && !$test->{update};
diff --git a/t/cobrand/brent.t b/t/cobrand/brent.t
index 662f8bd1615..3ff8bcfebfe 100644
--- a/t/cobrand/brent.t
+++ b/t/cobrand/brent.t
@@ -83,7 +83,7 @@ use_ok 'FixMyStreet::Cobrand::Brent';
my $super_user = $mech->create_user_ok('superuser@example.com', is_superuser => 1, name => "Super User");
my $comment_user = $mech->create_user_ok('comment@example.org', email_verified => 1, name => 'Brent');
-my $brent = $mech->create_body_ok(2488, 'Brent', {
+my $brent = $mech->create_body_ok(2488, 'Brent Council', {
api_key => 'abc',
jurisdiction => 'brent',
endpoint => 'http://endpoint.example.org',
@@ -94,6 +94,28 @@ my $brent = $mech->create_body_ok(2488, 'Brent', {
cobrand => 'brent'
});
my $atak_contact = $mech->create_contact_ok(body_id => $brent->id, category => 'ATAK', email => 'ATAK');
+
+FixMyStreet::DB->resultset('BodyArea')->find_or_create({
+ area_id => 2505, # Camden
+ body_id => $brent->id,
+});
+
+my $camden = $mech->create_body_ok(2505, 'Camden Borough Council', {},{cobrand => 'camden'});
+my $barnet = $mech->create_body_ok(2489, 'Barnet Borough Council');
+my $harrow = $mech->create_body_ok(2487, 'Harrow Borough Council');
+FixMyStreet::DB->resultset('BodyArea')->find_or_create({
+ area_id => 2488,
+ body_id => $barnet->id,
+});
+FixMyStreet::DB->resultset('BodyArea')->find_or_create({
+ area_id => 2488,
+ body_id => $camden->id,
+});
+FixMyStreet::DB->resultset('BodyArea')->find_or_create({
+ area_id => 2488,
+ body_id => $harrow->id,
+});
+
my $contact = $mech->create_contact_ok(body_id => $brent->id, category => 'Graffiti', email => 'graffiti@example.org');
my $gully = $mech->create_contact_ok(body_id => $brent->id, category => 'Gully grid missing',
email => 'Symology-gully', group => ['Drains and gullies']);
@@ -419,10 +441,14 @@ FixMyStreet::override_config {
subtest "hides the TfL River Piers category" => sub {
my $tfl = $mech->create_body_ok(2488, 'TfL');
+ FixMyStreet::DB->resultset('BodyArea')->find_or_create({
+ area_id => 2505, # Camden
+ body_id => $tfl->id,
+ });
$mech->create_contact_ok(body_id => $tfl->id, category => 'River Piers', email => 'tfl@example.org');
$mech->create_contact_ok(body_id => $tfl->id, category => 'River Piers - Cleaning', email => 'tfl@example.org');
$mech->create_contact_ok(body_id => $tfl->id, category => 'River Piers Damage doors and glass', email => 'tfl@example.org');
-
+ $mech->create_contact_ok(body_id => $tfl->id, category => 'Sweeping', email => 'tfl@example.org');
ok $mech->host('brent.fixmystreet.com'), 'set host';
my $json = $mech->get_ok_json('/report/new/ajax?latitude=51.55904&longitude=-0.28168');
is $json->{by_category}->{"River Piers"}, undef, "Brent doesn't have River Piers category";
@@ -451,6 +477,148 @@ FixMyStreet::override_config {
};
};
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'brent', 'tfl', 'camden', 'fixmystreet' ],
+ MAPIT_URL => 'http://mapit.uk/',
+}, sub {
+ $mech->create_contact_ok(body_id => $camden->id, category => 'Dead animal', email => 'animal@camden.org');
+ $mech->create_contact_ok(body_id => $camden->id, category => 'Fly-tipping', email => 'flytipping@camden.org');
+ $mech->create_contact_ok(body_id => $barnet->id, category => 'Abandoned vehicles', email => 'vehicles@barnet.org');
+ $mech->create_contact_ok(body_id => $barnet->id, category => 'Parking', email => 'parking@barnet.org');
+
+ my $brent_mock = Test::MockModule->new('FixMyStreet::Cobrand::Brent');
+ my $camden_mock = Test::MockModule->new('FixMyStreet::Cobrand::Camden');
+ foreach my $host (qw/brent fixmystreet/) {
+ subtest "categories on $host cobrand in Brent on Camden cobrand layer" => sub {
+ $mech->host("$host.fixmystreet.com");
+ $brent_mock->mock('_fetch_features', sub { [{ 'ms:BrentDiffs' => { 'ms:name' => 'Camden' } } ]});
+ $mech->get_ok("/report/new/ajax?longitude=-0.28168&latitude=51.55904");
+ is $mech->content_contains("Potholes"), 1, 'Brent category present';
+ is $mech->content_lacks("Gully grid missing"), 1, 'Brent Symology category not present';
+ is $mech->content_contains("Sweeping"), 1, 'TfL category present';
+ is $mech->content_contains("Fly-tipping"), 1, 'Camden category present';
+ is $mech->content_lacks("Dead animal"), 1, 'Camden non-street category not present';
+ is $mech->content_lacks("Abandoned vehicles"), 1, 'Barnet non-street category not present';
+ is $mech->content_lacks("Parking"), 1, 'Barnet street category not present';
+ }
+ };
+
+ foreach my $host (qw/brent fixmystreet/) {
+ subtest "categories on $host cobrand in Brent not on cobrand layer" => sub {
+ $mech->host("$host.fixmystreet.com");
+ $brent_mock->mock('_fetch_features', sub {[]});
+ $mech->get_ok("/report/new/ajax?longitude=-0.28168&latitude=51.55904");
+ is $mech->content_contains("Potholes"), 1, 'Brent category present';
+ is $mech->content_contains("Gully grid missing"), 1, 'Brent Symology category present';
+ is $mech->content_contains("Sweeping"), 1, 'TfL category present';
+ is $mech->content_lacks("Fly-tipping"), 1, 'Camden category not present';
+ is $mech->content_lacks("Dead animal"), 1, 'Camden non-street category not present';
+ is $mech->content_lacks("Abandoned vehicles"), 1, 'Barnet non-street category not present';
+ is $mech->content_lacks("Parking"), 1, 'Barnet street category not present';
+ };
+ };
+
+ foreach my $host (qw/camden fixmystreet/) {
+ subtest "categories on $host in Camden not on cobrand layer" => sub {
+ $mech->host("$host.fixmystreet.com");
+ $camden_mock->mock('_fetch_features', sub { [] });
+ $mech->get_ok("/report/new/ajax?longitude=-0.124514&latitude=51.529432");
+ is $mech->content_lacks("Potholes"), 1, 'Brent category not present';
+ is $mech->content_lacks("Gully grid missing"), 1, 'Brent Symology category not present';
+ is $mech->content_contains("Sweeping"), 1, 'TfL category present';
+ is $mech->content_contains("Fly-tipping"), 1, 'Camden category present';
+ is $mech->content_contains("Dead animal"), 1, 'Camden non-street category present';
+ is $mech->content_lacks("Abandoned vehicles"), 1, 'Barnet non-street category not present';
+ is $mech->content_lacks("Parking"), 1, 'Barnet street category not present';
+ };
+ }
+
+ foreach my $host (qw/fixmystreet brent camden/) {
+ subtest "categories on $host cobrand in Camden on Brent cobrand layer" => sub {
+ $mech->host("$host.fixmystreet.com");
+ $brent_mock->mock('_fetch_features',
+ sub { [ { 'ms:BrentDiffs' => { 'ms:name' => 'Brent' } } ] });
+ $camden_mock->mock('_fetch_features',
+ sub { [ { 'ms:BrentDiffs' => { 'ms:name' => 'Brent' } } ] });
+ $mech->get_ok("/report/new/ajax?longitude=-0.124514&latitude=51.529432");
+ is $mech->content_lacks("Potholes"), 1, 'Brent category not present';
+ is $mech->content_contains("Gully grid missing"), 1, 'Brent Symology category present';
+ is $mech->content_contains("Sweeping"), 1, 'TfL category present';
+ is $mech->content_lacks("Fly-tipping"), 1, 'Camden street category not present';
+ is $mech->content_contains("Dead animal"), 1, 'Camden non-street category present';
+ }
+ };
+
+ foreach my $host (qw/fixmystreet brent/) {
+ subtest "categories on $host cobrand in Brent on Barnet cobrand layer" => sub {
+ $mech->host("$host.fixmystreet.com");
+ $brent_mock->mock('_fetch_features', sub {[ { 'ms:BrentDiffs' => { 'ms:name' => 'Barnet' } } ]});
+ $mech->get_ok("/report/new/ajax?longitude=-0.28168&latitude=51.55904");
+ is $mech->content_lacks("Abandoned vehicles"), 1, 'Barnet non-street category not present';
+ is $mech->content_contains("Parking"), 1, 'Barnet street category present';
+ is $mech->content_lacks("Gully grid missing"), 1, 'Brent Symology category not present';
+ is $mech->content_contains("Potholes"), 1, 'Brent category present';
+ is $mech->content_contains("Sweeping"), 1, 'TfL category present';
+ is $mech->content_lacks("Fly-tipping"), 1, 'Camden category not present';
+ is $mech->content_lacks("Dead animal"), 1, 'Camden non-street category not present';
+ }
+ };
+
+ subtest "can not access Camden from Brent off asset layer" => sub {
+ $mech->host("brent.fixmystreet.com");
+ $brent_mock->mock('_fetch_features',
+ sub { [] });
+ $mech->get_ok("/report/new?longitude=-0.124514&latitude=51.529432");
+ is $mech->content_contains('That location is not covered by Brent Council'), 1, 'Can not make report in Camden off asset';
+ };
+
+ subtest "can access Camden from Brent on asset layer" => sub {
+ $mech->host("brent.fixmystreet.com");
+ $brent_mock->mock('_fetch_features',
+ sub { [{ 'ms:BrentDiffs' => { 'ms:name' => 'Brent' } }] });
+ $mech->get_ok("/report/new?longitude=-0.124514&latitude=51.529432");
+ is $mech->content_lacks('That location is not covered by Brent Council'), 1, 'Can not make report in Camden off asset';
+ };
+
+ subtest "can access Brent from Camden on Camden asset layer" => sub {
+ $mech->host("camden.fixmystreet.com");
+ $camden_mock->mock('_fetch_features', sub { [{ 'ms:BrentDiffs' => { 'ms:name' => 'Camden' } }] });
+ $mech->get_ok("/report/new?longitude=-0.28168&latitude=51.55904");
+ is $mech->content_lacks('That location is not covered by Camden Council'), 1, "Can make a report on Camden asset";
+ };
+
+ subtest "can not access Brent from Camden not on asset layer" => sub {
+ $mech->host("camden.fixmystreet.com");
+ $camden_mock->mock('_fetch_features', sub { [] });
+ $mech->get_ok("/report/new?longitude=-0.28168&latitude=51.55904");
+ is $mech->content_contains('That location is not covered by Camden Council'), 1, "Can make a report on Camden asset";
+ };
+
+ for my $test (
+ {
+ council => 'Brent',
+ location => '/report/new?longitude=-0.28168&latitude=51.55904',
+ asset => [ ],
+ },
+ {
+ council => 'Barnet',
+ location => '/report/new?longitude=-0.207702&latitude=51.558568',
+ asset => [ ],
+ },
+
+ ) {
+ subtest "can not access $test->{council} from Camden cobrand" => sub {
+ $mech->host("camden.fixmystreet.com");
+ $camden_mock->mock('_fetch_features', sub { $test->{asset} });
+ $mech->get_ok($test->{location});
+ is $mech->content_contains('That location is not covered by Camden Council'), 1, "Can not make report in $test->{council} from Camden";
+ };
+ };
+
+ $mech->host("brent.fixmystreet.com");
+ undef $brent_mock; undef $camden_mock;
+};
+
package SOAP::Result;
sub result { return $_[0]->{result}; }
sub new { my $c = shift; bless { @_ }, $c; }
@@ -660,7 +828,7 @@ FixMyStreet::override_config {
};
FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ 'brent' ],
+ ALLOWED_COBRANDS => [ 'brent', 'tfl' ],
MAPIT_URL => 'http://mapit.uk/',
STAGING_FLAGS => { send_reports => 1, skip_checks => 0 },
COBRAND_FEATURES => {