forked from e621ng/e621ng
[WikiPages] Fix exception on show_or_new without arg
This now uses `titled` which didn't handle nil
This commit is contained in:
parent
d2d6e83537
commit
3229106431
@ -50,7 +50,7 @@ class WikiPage < ApplicationRecord
|
||||
|
||||
module SearchMethods
|
||||
def titled(title)
|
||||
find_by(title: title.downcase.tr(" ", "_"))
|
||||
find_by(title: title&.downcase&.tr(" ", "_"))
|
||||
end
|
||||
|
||||
def active
|
||||
|
@ -61,6 +61,7 @@ class WikiPageTest < ActiveSupport::TestCase
|
||||
|
||||
should "search by title" do
|
||||
assert_equal("hot_potato", WikiPage.titled("hot potato").title)
|
||||
assert_nil(WikiPage.titled(nil))
|
||||
end
|
||||
|
||||
should "search other names with wildcards" do
|
||||
|
Loading…
Reference in New Issue
Block a user