FIX: search server side error in rare condition

This commit is contained in:
Sam 2018-05-28 15:28:02 +10:00
parent 0b55416742
commit e501936405
2 changed files with 5 additions and 0 deletions

View File

@ -374,6 +374,8 @@ class Search
exact = true
slug = match.to_s.split(":")
next if slug.empty?
if slug[1]
# sub category
parent_category_id = Category.where(slug: slug[0].downcase, parent_category_id: nil).pluck(:id).first

View File

@ -837,6 +837,9 @@ describe Search do
results = Search.new('#777').execute
expect(results.posts.length).to eq(0)
results = Search.new('xxx #:').execute
expect(results.posts.length).to eq(0)
end
context 'tags' do