diff options
author | Struan Donald <struan@exo.org.uk> | 2018-10-03 14:44:33 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2018-10-09 11:10:37 +0100 |
commit | 675ec6e6d741be456b287479ea517cc46c4270be (patch) | |
tree | 4c5f2f0672ab5f2f63f87273ce46e2a95518fa14 | |
parent | 66da7757654bef6bbbc92704552571bfe0d390ca (diff) |
[Oxfordshire] allow searching on ENQ customer_reference
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Oxfordshire.pm | 16 | ||||
-rw-r--r-- | t/cobrand/oxfordshire.t | 14 |
2 files changed, 30 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index cac79a347..f03f1b605 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -53,6 +53,22 @@ sub users_can_hide { return 1; } sub default_show_name { 0 } +sub lookup_by_ref_regex { + return qr/^\s*((?:ENQ)?\d+)\s*$/; +} + +sub lookup_by_ref { + my ($self, $ref) = @_; + + if ( $ref =~ /^ENQ/ ) { + my $len = length($ref); + my $filter = "%T18:customer_reference,T$len:$ref,%"; + return { 'extra' => { -like => $filter } }; + } + + return 0; +} + =head2 problem_response_days Returns the number of working days that are expected to elapse diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index 19a82742a..cec8f53b3 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -186,6 +186,20 @@ subtest 'Reports are marked as inspected correctly' => sub { }; }; +subtest 'can use customer reference to search for reports' => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'oxfordshire' ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + my $problem = $problems[0]; + $problem->set_extra_metadata( customer_reference => 'ENQ12456' ); + $problem->update; + + $mech->get_ok('/around?pc=ENQ12456'); + is $mech->uri->path, '/report/' . $problem->id, 'redirects to report'; + }; +}; + END { done_testing(); } |