aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm15
-rw-r--r--t/app/controller/around.t23
-rw-r--r--templates/web/base/around/lookup_by_ref.html6
-rw-r--r--templates/web/oxfordshire/_email_sent_extra.html3
5 files changed, 32 insertions, 16 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a36271bf7..3a39807e3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@
- Admin improvements:
- Character length limit can be placed on report detailed information #1848
- Inspector panel shows nearest address if available #1850
+ - Return a 200 rather than 404 for ref ID lookup.
* v2.2 (13th September 2017)
- New features:
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index b872084ff..30c023317 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -8,6 +8,7 @@ use FixMyStreet::Map;
use Encode;
use JSON::MaybeXS;
use Utils;
+use Try::Tiny;
=head1 NAME
@@ -366,13 +367,17 @@ sub lookup_by_ref : Private {
external_id => $ref
]);
- if ( $problems->count == 0) {
- $c->detach( '/page_error_404_not_found', [] );
- } elsif ( $problems->count == 1 ) {
- $c->res->redirect( $c->uri_for( '/report', $problems->first->id ) );
- } else {
+ my $count = try {
+ $problems->count;
+ } catch {
+ 0;
+ };
+
+ if ($count > 1) {
$c->stash->{ref} = $ref;
$c->stash->{matching_reports} = [ $problems->all ];
+ } elsif ($count == 1) {
+ $c->res->redirect( $c->uri_for( '/report', $problems->first->id ) );
}
}
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index fbb4e76cd..cdaeaf363 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -92,15 +92,22 @@ foreach my $test (
};
}
-subtest 'check non public reports are not displayed on around page' => sub {
- my $params = {
- postcode => 'EH1 1BB',
- latitude => 55.9519637512,
- longitude => -3.17492254484,
- };
- my @edinburgh_problems =
- $mech->create_problems_for_body( 5, 2651, 'Around page', $params );
+my @edinburgh_problems = $mech->create_problems_for_body( 5, 2651, 'Around page', {
+ postcode => 'EH1 1BB',
+ latitude => 55.9519637512,
+ longitude => -3.17492254484,
+});
+subtest 'check lookup by reference' => sub {
+ $mech->get_ok('/');
+ $mech->submit_form_ok( { with_fields => { pc => 'ref:12345' } }, 'bad ref');
+ $mech->content_contains('Searching found no reports');
+ my $id = $edinburgh_problems[0]->id;
+ $mech->submit_form_ok( { with_fields => { pc => "ref:$id" } }, 'good ref');
+ is $mech->uri->path, "/report/$id", "redirected to report page";
+};
+
+subtest 'check non public reports are not displayed on around page' => sub {
$mech->get_ok('/');
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
diff --git a/templates/web/base/around/lookup_by_ref.html b/templates/web/base/around/lookup_by_ref.html
index aded05638..5c08a7ceb 100644
--- a/templates/web/base/around/lookup_by_ref.html
+++ b/templates/web/base/around/lookup_by_ref.html
@@ -1,7 +1,7 @@
[% pre_container_extra = INCLUDE 'around/postcode_form.html', pc = ref %]
[% INCLUDE 'header.html', title = loc('Reporting a problem'), bodyclass = 'frontpage fullwidthpage' %]
-<div class="tablewrapper">
+[% IF matching_reports %]
<p>[% loc('We found more than one match for that problem reference:') %]</p>
<ul class="pc_alternatives">
[% FOREACH report IN matching_reports %]
@@ -13,6 +13,8 @@
</li>
[% END %]
</ul>
-</div>
+ [% ELSE %]
+ <p>[% loc('Searching found no reports.') %]</p>
+[% END %]
[% INCLUDE 'footer.html' %]
diff --git a/templates/web/oxfordshire/_email_sent_extra.html b/templates/web/oxfordshire/_email_sent_extra.html
index 5fdcd3bfd..f01c2d5fb 100644
--- a/templates/web/oxfordshire/_email_sent_extra.html
+++ b/templates/web/oxfordshire/_email_sent_extra.html
@@ -1 +1,2 @@
-[% INCLUDE '_response_time.html' problem=report %]
+[% DEFAULT problem = report %]
+[% IF problem %][% INCLUDE '_response_time.html' %][% END %]