diff options
author | Struan Donald <struan@exo.org.uk> | 2020-08-21 13:41:20 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2020-09-10 10:53:41 +0100 |
commit | 4b6baae9c4ac6353357a2f46355aa7eb9c8c10ec (patch) | |
tree | 044b0c78660713bfc3c6636d3bfa8cd4dcf0c15d | |
parent | 7048c1fd5a83714641029ab1d0b22574a64388bd (diff) |
[UK] enable extra state mapping in config
Add a cobrand feature that enables a state and external status
combination to be mapped to a new display string.
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Northamptonshire.pm | 13 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 13 | ||||
-rw-r--r-- | t/cobrand/northamptonshire.t | 79 |
3 files changed, 92 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Northamptonshire.pm b/perllib/FixMyStreet/Cobrand/Northamptonshire.pm index 26c8706cc..791e2f83f 100644 --- a/perllib/FixMyStreet/Cobrand/Northamptonshire.pm +++ b/perllib/FixMyStreet/Cobrand/Northamptonshire.pm @@ -75,19 +75,6 @@ sub problems_on_map_restriction { return $self->problems_restriction($rs); } -sub problem_state_processed { - my ($self, $comment) = @_; - - my $state = $comment->problem_state || ''; - my $code = $comment->get_extra_metadata('external_status_code') || ''; - - if ( $state eq 'investigating' and $code eq 'further' ) { - $state = 'Under further investigation'; - } - - return $state; -} - sub privacy_policy_url { 'https://www3.northamptonshire.gov.uk/councilservices/council-and-democracy/transparency/information-policies/privacy-notice/place/Pages/street-doctor.aspx' } diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index 4634f4b14..f472876ef 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -270,6 +270,19 @@ sub relative_url_for_report { return FixMyStreet->config('BASE_URL'); } +sub problem_state_processed { + my ($self, $comment) = @_; + + my $state = $comment->problem_state || ''; + my $code = $comment->get_extra_metadata('external_status_code') || ''; + + my $cfg = $self->feature('extra_state_mapping'); + + $state = ( $cfg->{$state}->{$code} || $state ) if $cfg->{$state}; + + return $state; +} + sub admin_allow_user { my ( $self, $user ) = @_; return 1 if $user->is_superuser; diff --git a/t/cobrand/northamptonshire.t b/t/cobrand/northamptonshire.t index 11b22bdb0..5758f700f 100644 --- a/t/cobrand/northamptonshire.t +++ b/t/cobrand/northamptonshire.t @@ -114,6 +114,15 @@ subtest 'check further investigation state' => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ { northamptonshire => '.' } ], MAPIT_URL => 'http://mapit.uk/', + COBRAND_FEATURES => { + extra_state_mapping => { + northamptonshire => { + investigating => { + further => 'Under further investigation' + } + } + } + } }, sub { $mech->get_ok('/report/' . $comment->problem_id); }; @@ -126,6 +135,76 @@ subtest 'check further investigation state' => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ { northamptonshire => '.' } ], MAPIT_URL => 'http://mapit.uk/', + COBRAND_FEATURES => { + extra_state_mapping => { + northamptonshire => { + investigating => { + further => 'Under further investigation' + } + } + } + } + }, sub { + $mech->get_ok('/report/' . $comment->problem_id); + }; + + $mech->content_contains('Under further investigation'); + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { northamptonshire => '.' } ], + MAPIT_URL => 'http://mapit.uk/', + COBRAND_FEATURES => { + extra_state_mapping => { + northamptonshire => { + fixed => { + further => 'Under further investigation' + } + }, + fixmystreet => { + 'Northamptonshire County Council' => { + fixed => { + further => 'Under further investigation' + } + } + } + } + } + }, sub { + $mech->get_ok('/report/' . $comment->problem_id); + }; + + $mech->content_contains('Investigating'); + $mech->content_lacks('Under further investigation'); + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { northamptonshire => '.' } ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->get_ok('/report/' . $comment->problem_id); + }; + + $mech->content_contains('Investigating'); + $mech->content_lacks('Under further investigation'); + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], + MAPIT_URL => 'http://mapit.uk/', + COBRAND_FEATURES => { + extra_state_mapping => { + northamptonshire => { + investigating => { + further => 'Under further investigation' + } + }, + fixmystreet => { + 'Northamptonshire County Council' => { + investigating => { + further => 'Under further investigation' + } + } + } + } + } }, sub { $mech->get_ok('/report/' . $comment->problem_id); }; |