unaccents Debate.search terms and tests that

This commit is contained in:
David Gil
2015-09-10 20:59:46 +02:00
parent 49ca331fa3
commit 1833c83351
2 changed files with 3 additions and 3 deletions

View File

@@ -138,7 +138,7 @@ class Debate < ActiveRecord::Base
end
def self.search(terms)
terms.present? ? where("title ILIKE ? OR description ILIKE ?", "%#{terms}%", "%#{terms}%") : none
terms.present? ? where("unaccent(title) ILIKE unaccent(?) OR unaccent(description) ILIKE unaccent(?)", "%#{terms}%", "%#{terms}%") : none
end
def conflictive?

View File

@@ -439,10 +439,10 @@ feature 'Debates' do
debate1 = create(:debate, title: "Show me what you got")
debate2 = create(:debate, title: "Get Schwifty")
debate3 = create(:debate)
debate4 = create(:debate, description: "Schwifty in here")
debate4 = create(:debate, description: "Schwíftÿ in here")
visit debates_path
fill_in "search", with: "Schwifty"
fill_in "search", with: "Schwìfty"
click_button "Search"
within("#debates") do