mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-18 13:38:24 -04:00
make crop search case insensitive
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user