aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Open311.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Contact.pm5
-rw-r--r--t/app/controller/report_new.t26
4 files changed, 33 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm
index 6829e01ae..a5f4a53e7 100644
--- a/perllib/FixMyStreet/App/Controller/Open311.pm
+++ b/perllib/FixMyStreet/App/Controller/Open311.pm
@@ -160,7 +160,7 @@ sub get_services : Private {
my $lon = $c->get_param('long') || '';
# Look up categories for this council or councils
- my $categories = $c->model('DB::Contact')->not_deleted;
+ my $categories = $c->model('DB::Contact')->active;
if ($lat || $lon) {
my $area_types = $c->cobrand->area_types;
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 1d322e88c..3acb385bd 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -605,7 +605,7 @@ sub setup_categories_and_bodies : Private {
my $contacts #
= $c #
->model('DB::Contact') #
- ->not_deleted #
+ ->active
->search( { body_id => [ keys %bodies ] } );
my @contacts = $c->cobrand->categories_restriction($contacts)->all;
diff --git a/perllib/FixMyStreet/DB/ResultSet/Contact.pm b/perllib/FixMyStreet/DB/ResultSet/Contact.pm
index d32453942..8ef6d1ac5 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Contact.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Contact.pm
@@ -19,6 +19,11 @@ sub not_deleted {
return $rs->search( { $rs->me('state') => { '!=' => 'deleted' } } );
}
+sub active {
+ my $rs = shift;
+ $rs->search( { $rs->me('state') => [ 'unconfirmed', 'confirmed' ] } );
+}
+
sub summary_count {
my ( $rs, $restriction ) = @_;
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 52bf6da3e..ab6b5d78e 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -890,6 +890,32 @@ foreach my $test (
}
+subtest "Test inactive categories" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ BASE_URL => 'https://www.fixmystreet.com',
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ # Around and New report have both categories
+ $mech->get_ok('/around?pc=GL50+2PR');
+ $mech->content_contains('Potholes');
+ $mech->content_contains('Trees');
+ $mech->get_ok("/report/new?lat=$saved_lat&lon=$saved_lon");
+ $mech->content_contains('Potholes');
+ $mech->content_contains('Trees');
+ $contact2->update( { state => 'inactive' } ); # Potholes
+ # But when Potholes is inactive, it's not on New report
+ $mech->get_ok('/around?pc=GL50+2PR');
+ $mech->content_contains('Potholes');
+ $mech->content_contains('Trees');
+ $mech->get_ok("/report/new?lat=$saved_lat&lon=$saved_lon");
+ $mech->content_lacks('Potholes');
+ $mech->content_contains('Trees');
+ # Change back
+ $contact2->update( { state => 'confirmed' } );
+ };
+};
+
subtest "test report creation for a category that is non public" => sub {
$mech->log_out_ok;
$mech->clear_emails_ok;