Permalink
Browse files

Ignore blank array values when passed to the Search class

  • Loading branch information...
binarylogic committed Jun 13, 2009
1 parent b418206 commit e77b2a476e4fc0313f4a86a456a9f9821c1b6304
Showing with 7 additions and 0 deletions.
  1. +1 −0 lib/searchlogic/search.rb
  2. +6 −0 spec/search_spec.rb
@@ -27,6 +27,7 @@ def conditions
def conditions=(values)
values.each do |condition, value|
+ value.delete_if { |v| v.blank? } if value.is_a?(Array)
next if value.blank?
send("#{condition}=", value)
end
View
@@ -47,6 +47,12 @@
search.conditions = {"username" => ""}
search.username.should be_nil
end
+
+ it "should ignore blank values in arrays" do
+ search = User.search
+ search.conditions = {"username_equals_any" => [""]}
+ search.username_equals_any.should be_blank
+ end
end
context "condition accessors" do

0 comments on commit e77b2a4

Please sign in to comment.