spec/search_spec.rb in searchlogic-2.4.2 vs spec/search_spec.rb in searchlogic-2.4.3

- old
+ new

@@ -67,14 +67,16 @@ search = User.search search.conditions = {"username" => "bjohnson"} search.username.should == "bjohnson" end - it "should ignore blank values" do + # We ignore them upon execution. But we still want to accept the condition so that returning the conditions + # preserves the values. + it "should not ignore blank values" do search = User.search search.conditions = {"username" => ""} - search.username.should be_nil + search.username.should == "" end it "should use custom scopes before normalizing" do User.create(:username => "bjohnson") User.named_scope :username, lambda { |value| {:conditions => {:username => value.reverse}} } @@ -85,11 +87,11 @@ end it "should ignore blank values in arrays" do search = User.search search.conditions = {"username_equals_any" => [""]} - search.username_equals_any.should be_blank + search.username_equals_any.first.should be_blank end end context "condition accessors" do it "should allow setting exact columns individually" do @@ -358,9 +360,27 @@ it "should not split out dates or times (big fix)" do s = User.search s.created_at_after = Time.now lambda { s.count }.should_not raise_error + end + + it "should ignore blank values" do + search = User.search + search.conditions = {"username_equals" => ""} + search.proxy_options.should == {} + end + + it "should not ignore blank values when explicitly set" do + search = User.search + search.username_equals = "" + search.proxy_options.should == {:conditions => ["users.username = ?", ""]} + end + + it "should ignore blank values in arrays" do + search = User.search + search.conditions = {"username_equals_any" => [""]} + search.proxy_options.should == {} end end context "method delegation" do it "should respond to count" do