Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions perllib/FixMyStreet/Cobrand/Gloucestershire.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,32 @@ sub council_url { 'gloucestershire' }

sub admin_user_domain { 'gloucestershire.gov.uk' }

=item * Allows anonymous reporting
=item * Allows anonymous reporting (but not for Gloucester City categories)

=cut

sub allow_anonymous_reports { 'button' }
sub allow_anonymous_reports {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is the same as Default's now, apart from it doesn't have the anonymous_allowed check. So perhaps here instead we could remove this function entirely and tick every category for Gloucestershire to have the same effect without special code?

my ($self, $category_name, $lookup) = @_;

# Get category from stash if not provided
$category_name ||= $self->{c}->stash->{category};

return 0 unless $category_name;

return $lookup->{$category_name} if $lookup && $lookup->{$category_name};

# Find the contact for this category in our body only
my $contact_rs = FixMyStreet::DB->resultset("Contact")->search({
body_id => $self->body->id,
category => $category_name
});

# Allow anonymous only for our body's categories
return 'button' if $contact_rs->first;

# Deny for other bodies' categories
return 0;
}

=item * Gloucestershire use their own privacy policy

Expand Down
22 changes: 22 additions & 0 deletions t/cobrand/gloucestershire.t
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,28 @@ FixMyStreet::override_config {
is $alert, undef, "no alert created";
};

subtest 'anonymous reporting only allowed for Gloucestershire categories' => sub {
# Create a Gloucester body and category
my $gloucester_body = $mech->create_body_ok(
2325,
'Gloucester City Council',
{ cobrand => 'gloucester' },
);
my $gloucester_category = $mech->create_contact_ok(
body_id => $gloucester_body->id,
category => 'Broken glass',
email => 'GLOUCESTER_GLASS',
);

# Test Gloucestershire category (should allow)
is $cobrand->allow_anonymous_reports('Graffiti'), 'button',
'Anonymous allowed for Gloucestershire category';

# Test Gloucester category (should deny)
is $cobrand->allow_anonymous_reports('Broken glass'), 0,
'Anonymous denied for Gloucester category';
};

for my $host ( 'fixmystreet', 'gloucestershire' ) {
ok $mech->host($host), "change host to $host";

Expand Down
Loading