From 08f833ba7a5c276668ac5f44ffe3db536bb3ce78 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Sat, 18 Sep 2010 17:21:18 -0700 Subject: [PATCH] case insensitivity on search --- app/models/person.rb | 2 +- spec/models/person_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index aac7b23ae..b1e7e3745 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -35,7 +35,7 @@ class Person /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix def self.search(query) - Person.all('profile.first_name' => /^#{query}/) | Person.all('profile.last_name' => /^#{query}/) + Person.all('profile.first_name' => /^#{query}/i) | Person.all('profile.last_name' => /^#{query}/i) end def real_name diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index bffe37f85..4f236b733 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -134,13 +134,13 @@ describe Person do people.include?(@friend_three).should == false people.include?(@friend_four).should == false - people = Person.search("Wei") + people = Person.search("wEi") people.include?(@friend_two).should == true people.include?(@friend_one).should == false people.include?(@friend_three).should == false people.include?(@friend_four).should == false - people = Person.search("Gri") + people = Person.search("gri") people.include?(@friend_one).should == true people.include?(@friend_four).should == true people.include?(@friend_two).should == false