posts: fix error when viewing nonexistent post IDs.

This commit is contained in:
evazion
2021-04-01 18:24:26 -05:00
parent d58a0bf1e4
commit 26496bba8d
2 changed files with 9 additions and 1 deletions

View File

@@ -18,7 +18,7 @@
<% end %>
<%# XXX hack to only load Ruffle on Flash posts %>
<% if controller_name == "posts" && action_name == "show" && @post.is_flash? %>
<% if controller_name == "posts" && action_name == "show" && @post&.is_flash? %>
<%= javascript_pack_tag "application", "flash" %>
<% else %>
<%= javascript_pack_tag "application" %>

View File

@@ -567,6 +567,14 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
end
end
context "a nonexistent post id" do
should "return 404" do
get post_path(id: 9_999_999)
assert_response 404
end
end
context "with pools" do
should "render the pool list" do
as(@user) { @post.update(tag_string: "newpool:comic") }