Permalink
Browse files

Fix Database#blank_object for objects that don't respond to empty?

  • Loading branch information...
1 parent d261b1e commit cabdbf40489013a0c17e578d6bb63bf4c47ee831 @jeremyevans jeremyevans committed Apr 2, 2009
Showing with 3 additions and 1 deletion.
  1. +1 −1 lib/sequel/database.rb
  2. +2 −0 spec/extensions/validation_helpers_spec.rb
View
2 lib/sequel/database.rb
@@ -587,7 +587,7 @@ def blank_object?(obj)
when String
obj.strip.empty?
else
- !obj.respond_to?(:empty?) || obj.empty?
+ obj.respond_to?(:empty?) ? obj.empty? : false
end
end
View
2 spec/extensions/validation_helpers_spec.rb
@@ -193,6 +193,8 @@ def o.blank?
@m.should be_valid
@m.value = false
@m.should be_valid
+ @m.value = Time.now
+ @m.should be_valid
end
it "should support validates_unique with a single attribute" do

0 comments on commit cabdbf4

Please sign in to comment.