diff options
-rwxr-xr-x | bin/browser-tests | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/BathNES.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Borsetshire.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Buckinghamshire.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 12 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Lincolnshire.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Northamptonshire.pm | 2 | ||||
-rw-r--r-- | perllib/Open311/PopulateServiceList.pm | 2 | ||||
-rw-r--r-- | t/app/controller/admin/bodies.t | 11 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 5 | ||||
-rw-r--r-- | t/open311/populate-service-list.t | 23 |
13 files changed, 32 insertions, 41 deletions
diff --git a/bin/browser-tests b/bin/browser-tests index 37f542c92..da6db6737 100755 --- a/bin/browser-tests +++ b/bin/browser-tests @@ -75,6 +75,9 @@ sub run { ALLOWED_COBRANDS => $cobrand, MAPIT_URL => $mapit_url, BASE_URL => 'http://fixmystreet.localhost:3001', + COBRAND_FEATURES => { + category_groups => { map { $_ => 1 } @$cobrand }, + } }); $ENV{FMS_OVERRIDE_CONFIG} = $config_out; @@ -95,10 +98,8 @@ sub run { kill 'TERM', $pid if $pid; exit $exit >> 8; } else { - use Test::MockModule; - my $c = Test::MockModule->new('FixMyStreet::Cobrand::FixMyStreet'); - $c->mock('enable_category_groups', sub { 1 }); # Child, run the server on port 3001 + require FixMyStreet; FixMyStreet->test_mode(1); # So email doesn't try to send local $ENV{FIXMYSTREET_APP_DEBUG} = 0; require Plack::Runner; diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 6a6040865..eb7934da3 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -741,7 +741,7 @@ sub setup_categories_and_bodies : Private { $c->stash->{missing_details_bodies} = \@missing_details_bodies; $c->stash->{missing_details_body_names} = \@missing_details_body_names; - if ( $c->cobrand->call_hook('enable_category_groups') ) { + if ( $c->cobrand->enable_category_groups ) { my %category_groups = (); for my $category (@category_options) { my $group = $category->{group} // $category->get_extra_metadata('group') // ''; diff --git a/perllib/FixMyStreet/Cobrand/BathNES.pm b/perllib/FixMyStreet/Cobrand/BathNES.pm index d726c671e..ea9b26e7a 100644 --- a/perllib/FixMyStreet/Cobrand/BathNES.pm +++ b/perllib/FixMyStreet/Cobrand/BathNES.pm @@ -74,8 +74,6 @@ sub pin_colour { sub send_questionnaires { 0 } -sub enable_category_groups { 1 } - sub default_map_zoom { 3 } sub map_js_extra { diff --git a/perllib/FixMyStreet/Cobrand/Borsetshire.pm b/perllib/FixMyStreet/Cobrand/Borsetshire.pm index a99d2e7b4..f8650169d 100644 --- a/perllib/FixMyStreet/Cobrand/Borsetshire.pm +++ b/perllib/FixMyStreet/Cobrand/Borsetshire.pm @@ -27,6 +27,4 @@ sub send_questionnaires { sub bypass_password_checks { 1 } -sub enable_category_groups { 1 } - 1; diff --git a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm index 486e9603d..4c1d0108b 100644 --- a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm +++ b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm @@ -185,8 +185,6 @@ sub map_type { 'Buckinghamshire' } sub default_map_zoom { 3 } -sub enable_category_groups { 1 } - sub _dashboard_export_add_columns { my $self = shift; my $c = $self->{c}; diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index cc7f03adb..225ab50d7 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -1085,6 +1085,18 @@ sub show_unconfirmed_reports { 0; } +=item enable_category_groups + +Whether body category groups should be displayed on the new report form. If this is +not enabled then any groups will be ignored and a flat list of categories displayed. + +=cut + +sub enable_category_groups { + my $self = shift; + return $self->feature('category_groups'); +} + sub default_problem_state { 'unconfirmed' } sub state_groups_admin { diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm index e01f3e23b..7c51eddd1 100644 --- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm +++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm @@ -10,8 +10,6 @@ use constant COUNCIL_ID_BROMLEY => 2482; sub on_map_default_status { return 'open'; } -sub enable_category_groups { 1 } - # Special extra sub path_to_web_templates { my $self = shift; diff --git a/perllib/FixMyStreet/Cobrand/Lincolnshire.pm b/perllib/FixMyStreet/Cobrand/Lincolnshire.pm index 3b731b273..ca88f6b8e 100644 --- a/perllib/FixMyStreet/Cobrand/Lincolnshire.pm +++ b/perllib/FixMyStreet/Cobrand/Lincolnshire.pm @@ -18,7 +18,6 @@ sub council_name { return 'Lincolnshire County Council'; } sub council_url { return 'lincolnshire'; } sub is_two_tier { 1 } -sub enable_category_groups { 1 } sub send_questionnaires { 0 } sub report_sent_confirmation_email { 'external_id' } diff --git a/perllib/FixMyStreet/Cobrand/Northamptonshire.pm b/perllib/FixMyStreet/Cobrand/Northamptonshire.pm index 3d5d4b6f2..21a145326 100644 --- a/perllib/FixMyStreet/Cobrand/Northamptonshire.pm +++ b/perllib/FixMyStreet/Cobrand/Northamptonshire.pm @@ -47,8 +47,6 @@ sub privacy_policy_url { 'https://www3.northamptonshire.gov.uk/councilservices/council-and-democracy/transparency/information-policies/privacy-notice/place/Pages/street-doctor.aspx' } -sub enable_category_groups { 1 } - sub is_two_tier { 1 } sub get_geocoder { 'OSM' } diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index 2da67e9cd..bbc00231f 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -262,7 +262,7 @@ sub _normalize_service_name { sub _set_contact_group { my ($self, $contact) = @_; - my $groups_enabled = $self->_current_body_cobrand && $self->_current_body_cobrand->call_hook('enable_category_groups'); + my $groups_enabled = $self->_current_body_cobrand && $self->_current_body_cobrand->enable_category_groups; my $old_group = $contact->get_extra_metadata('group') || ''; my $new_group = $groups_enabled ? $self->_current_service->{group} || '' : ''; diff --git a/t/app/controller/admin/bodies.t b/t/app/controller/admin/bodies.t index f67e45bf6..d2ae28e9d 100644 --- a/t/app/controller/admin/bodies.t +++ b/t/app/controller/admin/bodies.t @@ -1,10 +1,3 @@ -package FixMyStreet::Cobrand::Tester; - -use parent 'FixMyStreet::Cobrand::Default'; - -sub enable_category_groups { 1 } - -package main; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -210,10 +203,12 @@ subtest 'check text output' => sub { }; # END of override wrap FixMyStreet::override_config { - ALLOWED_COBRANDS => ['tester'], MAPIT_URL => 'http://mapit.uk/', MAPIT_TYPES => [ 'UTA' ], BASE_URL => 'http://www.example.org', + COBRAND_FEATURES => { + category_groups => { default => 1 }, + } }, sub { subtest 'group editing works' => sub { $mech->get_ok('/admin/body/' . $body->id); diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 848529686..d6b256be1 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -1271,11 +1271,12 @@ subtest "Test inactive categories" => sub { }; subtest "category groups" => sub { - my $cobrand = Test::MockModule->new('FixMyStreet::Cobrand::FixMyStreet'); - $cobrand->mock('enable_category_groups', sub { 1 }); FixMyStreet::override_config { ALLOWED_COBRANDS => 'fixmystreet', MAPIT_URL => 'http://mapit.uk/', + COBRAND_FEATURES => { + category_groups => { fixmystreet => 1 } + } }, sub { $contact2->update( { extra => { group => 'Roads' } } ); $contact9->update( { extra => { group => 'Roads' } } ); diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t index c67fae9bd..fc3423ae6 100644 --- a/t/open311/populate-service-list.t +++ b/t/open311/populate-service-list.t @@ -5,16 +5,6 @@ use parent 'FixMyStreet::Cobrand::Default'; sub council_area_id { 1 } - -package FixMyStreet::Cobrand::TesterGroups; - -use parent 'FixMyStreet::Cobrand::Default'; - -sub council_area_id { 1 } - -sub enable_category_groups { 1 } - - package main; use FixMyStreet::Test; @@ -51,13 +41,16 @@ $bucks->body_areas->create({ }); for my $test ( - { desc => 'groups not set for new contacts', cobrand => 'tester', groups => 0, delete => 1 }, - { desc => 'groups set for new contacts', cobrand => 'testergroups', groups => 1, delete => 1}, - { desc => 'groups removed for existing contacts', cobrand => 'tester', groups => 0, delete => 0 }, - { desc => 'groups added for existing contacts', cobrand => 'testergroups', groups => 1, delete => 0}, + { desc => 'groups not set for new contacts', enable_groups => 0, groups => 0, delete => 1 }, + { desc => 'groups set for new contacts', enable_groups => 1, groups => 1, delete => 1}, + { desc => 'groups removed for existing contacts', enable_groups => 0, groups => 0, delete => 0 }, + { desc => 'groups added for existing contacts', enable_groups => 1, groups => 1, delete => 0}, ) { FixMyStreet::override_config { - ALLOWED_COBRANDS => [ $test->{cobrand} ], + ALLOWED_COBRANDS => [ 'tester' ], + COBRAND_FEATURES => { + category_groups => { tester => $test->{enable_groups} }, + } }, sub { subtest 'check basic functionality, ' . $test->{desc} => sub { FixMyStreet::DB->resultset('Contact')->search( { body_id => $body->id } )->delete() if $test->{delete}; |