diff options
author | Edmund von der Burg <evdb@mysociety.org> | 2011-04-15 17:49:58 +0100 |
---|---|---|
committer | Edmund von der Burg <evdb@mysociety.org> | 2011-04-15 17:49:58 +0100 |
commit | 8cdbfa9706eb1e69f4e975646fcde99dd41a9064 (patch) | |
tree | c8a5383a76e9988cd8736d826d59ee227c8edc3b | |
parent | 49d6b2900ccc63b8c6c8022399b663b426fe9641 (diff) |
Show 410 page for hidden reports, and 404 for ones that are not confirmed yet.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 14 | ||||
-rw-r--r-- | t/app/controller/report_display.t | 20 |
2 files changed, 25 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 661505a49..fe6310bbf 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -65,15 +65,15 @@ sub display : Path('') : Args(1) { ? undef : $c->model('DB::Problem')->find( { id => $id } ); - if ( !$problem ) { # bad id or id not found + if ( !$problem || $problem->state eq 'unconfirmed' ) { $c->detach( '/page_error_404_not_found', [ _('Unknown problem ID') ] ); } - - # elsif () { - # - # } - -# return front_page($q, _('That report has been removed from FixMyStreet.'), '410 Gone') if $problem->{state} eq 'hidden'; + elsif ( $problem->state eq 'hidden' ) { + $c->detach( + '/page_error_410_gone', + [ _('That report has been removed from FixMyStreet.') ] # + ); + } # my $extra_data = Cobrand::extra_data($cobrand, $q); # my $google_link = Cobrand::base_url_for_emails($cobrand, $extra_data) diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index 24a62b958..f979cc4ed 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -64,13 +64,29 @@ subtest "test bad ids get dealt with (404)" => sub { } }; +subtest "change report to unconfirmed and check for 404 status" => sub { + ok $report->update( { state => 'unconfirmed' } ), 'unconfirm report'; + ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; + is $mech->res->code, 404, "page not found"; + is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; + $mech->content_contains('Unknown problem ID'); + ok $report->update( { state => 'confirmed' } ), 'confirm report again'; +}; + +subtest "change report to hidden and check for 410 status" => sub { + ok $report->update( { state => 'hidden' } ), 'hide report'; + ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; + is $mech->res->code, 410, "page gone"; + is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; + $mech->content_contains('That report has been removed from FixMyStreet.'); + ok $report->update( { state => 'confirmed' } ), 'confirm report again'; +}; + subtest "test a good report" => sub { $mech->get_ok("/report/$report_id"); is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; }; -fail "change report to hidden and check for 400 status"; - # tidy up $mech->delete_user('test@example.com'); done_testing(); |