posts: fix error on /posts?md5=<does_not_exist>.
This commit is contained in:
@@ -4,7 +4,7 @@ class PostsController < ApplicationController
|
||||
|
||||
def index
|
||||
if params[:md5].present?
|
||||
@post = Post.find_by_md5(params[:md5])
|
||||
@post = Post.find_by!(md5: params[:md5])
|
||||
respond_with(@post) do |format|
|
||||
format.html { redirect_to(@post) }
|
||||
end
|
||||
|
||||
@@ -132,6 +132,11 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
get posts_path, params: { md5: @post.md5 }
|
||||
assert_redirected_to(@post)
|
||||
end
|
||||
|
||||
should "return error on nonexistent md5" do
|
||||
get posts_path(md5: "foo")
|
||||
assert_response 404
|
||||
end
|
||||
end
|
||||
|
||||
context "with a random search" do
|
||||
|
||||
Reference in New Issue
Block a user