diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-10 11:11:30 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-10 11:11:30 +0200 |
commit | 7c353d576a5c302f50d5a72768e36f7a04e71add (patch) | |
tree | 14c3393c94b56e21bb1daad9192c9d73aa2f8dbc /activerecord/test/cases | |
parent | b6a2113b8d8301bc1b3cc8b9a1db2e270a24f7b3 (diff) | |
download | rails-7c353d576a5c302f50d5a72768e36f7a04e71add.tar.gz rails-7c353d576a5c302f50d5a72768e36f7a04e71add.tar.bz2 rails-7c353d576a5c302f50d5a72768e36f7a04e71add.zip |
Add failing tests according to #479.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 15 |
1 files changed, 15 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 526bceeea9..dc2481456b 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -79,6 +79,21 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal 'defaulty', bulb.name end + def test_create_from_association_set_owner_attributes_by_passing_protection + Bulb.attr_protected :car_id + car = Car.create(:name => 'honda') + + bulb = car.bulbs.new + assert_equal car.id, bulb.car_id + + bulb = car.bulbs.build + assert_equal car.id, bulb.car_id + + bulb = car.bulbs.create + assert_equal car.id, bulb.car_id + ensure + Bulb.attr_protected :id + 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. |