Browse files

add failing test

  • Loading branch information...
1 parent 926a313 commit 21a8743946bcfe32ae4f4ff6ee49d4e76d41c022 @mguterl committed Oct 1, 2011
Showing with 7 additions and 1 deletion.
  1. +5 −0 test/serialized_attributes_test.rb
  2. +2 −1 test/test_helper.rb
View
5 test/serialized_attributes_test.rb
@@ -238,6 +238,11 @@ def @record.title=(v)
assert !@record.data.key?('active')
end
+ test "ignores empty strings for booleans" do
+ @newbie.clearance = ""
+ assert_nil @newbie.clearance
+ end
+
test "attempts to re-encode data when saving" do
assert_not_nil @record.title
@record.raw_data = nil
View
3 test/test_helper.rb
@@ -76,7 +76,8 @@ class SerializedRecordWithDefaults < ActiveRecord::Base
boolean :active, :default => true
array :names, :default => %w(a b c)
hash :extras, :default => {:a => 1}
+ boolean :clearance, :default => nil
end
before_save { |r| false } # cancel the save
-end
+end

0 comments on commit 21a8743

Please sign in to comment.