[WikiPages] Fix exception on show_or_new without arg

This now uses `titled` which didn't handle nil
This commit is contained in:
Earlopain 2024-04-12 15:11:45 +02:00
parent d2d6e83537
commit 3229106431
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
2 changed files with 2 additions and 1 deletions

View File

@ -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

View File

@ -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