From 1e3add3be2e342fa30d8dc1a0f4ead28c47c97fe Mon Sep 17 00:00:00 2001 From: swag Date: Fri, 2 Jun 2023 15:51:40 -0400 Subject: [PATCH] New tests for 404 for hidden posts --- lib/PostText/Controller/Remark.pm | 2 +- t/moderator.t | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/PostText/Controller/Remark.pm b/lib/PostText/Controller/Remark.pm index c813802..453ad98 100644 --- a/lib/PostText/Controller/Remark.pm +++ b/lib/PostText/Controller/Remark.pm @@ -8,7 +8,7 @@ sub by_id($self) { $self->stash(remark => $remark); - $self->stash(error => 'Remark not found 🤷') + $self->stash(status => 404, error => 'Remark not found 🤷') unless keys %{$remark}; $self->render; diff --git a/t/moderator.t b/t/moderator.t index d60d753..c9d7b24 100644 --- a/t/moderator.t +++ b/t/moderator.t @@ -50,6 +50,12 @@ subtest Login => sub { $t->get_ok('/moderator/thread/hide/1') ->status_is(302) ->header_like(Location => qr{moderator/flagged}); + $t->get_ok('/moderator/thread/single/1') + ->status_is(200) + ->text_like(h2 => qr/Thread #/); + $t->get_ok('/thread/single/1') + ->status_is(404) + ->text_like(p => qr/Thread not found/); $t->get_ok('/moderator/thread/unhide/1') ->status_is(302) ->header_like(Location => qr{moderator/hidden}); @@ -57,6 +63,12 @@ subtest Login => sub { $t->get_ok('/moderator/remark/hide/1') ->status_is(302) ->header_like(Location => qr{moderator/flagged}); + $t->get_ok('/moderator/remark/single/1') + ->status_is(200) + ->text_like(h2 => qr/Remark #/); + $t->get_ok('/remark/single/1') + ->status_is(404) + ->text_like(p => qr/Remark not found/); $t->get_ok('/moderator/remark/unhide/1') ->status_is(302) ->header_like(Location => qr{moderator/hidden});