aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-05-10 11:02:34 +0200
committerJosé Valim <jose.valim@gmail.com>2011-05-10 11:02:34 +0200
commitb6a2113b8d8301bc1b3cc8b9a1db2e270a24f7b3 (patch)
treefbcb4efafaff816e4c3399fbf277149d9fe5debf /activerecord
parent9e4b715d790aa84dfb3d7aa332e0012cbc264394 (diff)
downloadrails-b6a2113b8d8301bc1b3cc8b9a1db2e270a24f7b3.tar.gz
rails-b6a2113b8d8301bc1b3cc8b9a1db2e270a24f7b3.tar.bz2
rails-b6a2113b8d8301bc1b3cc8b9a1db2e270a24f7b3.zip
Add failing tests, according to #480.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 247decc67b..526bceeea9 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -66,6 +66,20 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal 'exotic', bulb.name
end
+ def test_create_from_association_with_nil_values_should_work
+ car = Car.create(:name => 'honda')
+
+ bulb = car.bulbs.new(nil)
+ assert_equal 'defaulty', bulb.name
+
+ bulb = car.bulbs.build(nil)
+ assert_equal 'defaulty', bulb.name
+
+ bulb = car.bulbs.create(nil)
+ assert_equal 'defaulty', bulb.name
+ end
+
+
# When creating objects on the association, we must not do it within a scope (even though it
# would be convenient), because this would cause that scope to be applied to any callbacks etc.
def test_build_and_create_should_not_happen_within_scope