wiki pages: fix error in /wiki_pages/does_not_exist.json
This commit is contained in:
@@ -40,17 +40,19 @@ class WikiPagesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if params[:id] =~ /\A\d+\Z/
|
if params[:id] =~ /\A\d+\z/
|
||||||
@wiki_page = WikiPage.find(params[:id])
|
@wiki_page = WikiPage.find(params[:id])
|
||||||
else
|
else
|
||||||
@wiki_page = WikiPage.find_by_title(params[:id])
|
@wiki_page = WikiPage.titled(params[:id]).first
|
||||||
if @wiki_page.nil? && request.format.symbol == :html
|
|
||||||
redirect_to show_or_new_wiki_pages_path(:title => params[:id])
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_with(@wiki_page)
|
if @wiki_page.present?
|
||||||
|
respond_with(@wiki_page)
|
||||||
|
elsif request.format.html?
|
||||||
|
redirect_to show_or_new_wiki_pages_path(title: params[:id])
|
||||||
|
else
|
||||||
|
raise ActiveRecord::RecordNotFound
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|||||||
@@ -48,11 +48,16 @@ class WikiPagesControllerTest < ActionDispatch::IntegrationTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
should "redirect for a nonexistent title" do
|
should "redirect html requests for a nonexistent title" do
|
||||||
get wiki_page_path(:id => "what")
|
get wiki_page_path("what")
|
||||||
assert_redirected_to(show_or_new_wiki_pages_path(title: "what"))
|
assert_redirected_to(show_or_new_wiki_pages_path(title: "what"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "return 404 to api requests for a nonexistent title" do
|
||||||
|
get wiki_page_path("what"), as: :json
|
||||||
|
assert_response 404
|
||||||
|
end
|
||||||
|
|
||||||
should "render for a negated tag" do
|
should "render for a negated tag" do
|
||||||
as_user do
|
as_user do
|
||||||
@wiki_page.update(title: "-aaa")
|
@wiki_page.update(title: "-aaa")
|
||||||
|
|||||||
Reference in New Issue
Block a user