Permalink
Browse files

Add failing tests according to #479.

  • Loading branch information...
1 parent b6a2113 commit 7c353d576a5c302f50d5a72768e36f7a04e71add @josevalim josevalim committed May 10, 2011
Showing with 15 additions and 0 deletions.
  1. +15 −0 activerecord/test/cases/associations/has_many_associations_test.rb
@@ -79,6 +79,21 @@ def test_create_from_association_with_nil_values_should_work
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.

0 comments on commit 7c353d5

Please sign in to comment.