make crop search case insensitive

This commit is contained in:
Skud
2014-07-06 20:16:59 +10:00
parent 8897e5149d
commit 77d2b0e950
2 changed files with 4 additions and 1 deletions

View File

@@ -174,7 +174,7 @@ class Crop < ActiveRecord::Base
# searches for crops whose names match the string given
# just uses SQL LIKE for now, but can be made fancier later
def self.search(query)
where("name LIKE ?", "%#{query}%")
where("name ILIKE ?", "%#{query}%")
end
end

View File

@@ -321,6 +321,9 @@ describe Crop do
it "doesn't find non-matches" do
Crop.search('mush').should_not include @crop
end
it "searches case insensitively" do
Crop.search('mUsH').should include @mushroom
end
end
end