diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-06-22 14:11:12 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-06-22 14:11:12 +0200 |
commit | 951bde4557cde3e1da8a5545031498c97a4e03f0 (patch) | |
tree | 441b9c8c5229466e09510b6e385ff923409c0301 | |
parent | 763635e30f17800ebc0a8ae98d780edc8ebfb4e5 (diff) | |
download | rails-951bde4557cde3e1da8a5545031498c97a4e03f0.tar.gz rails-951bde4557cde3e1da8a5545031498c97a4e03f0.tar.bz2 rails-951bde4557cde3e1da8a5545031498c97a4e03f0.zip |
test-case to prevent regressions on `Association#build` with an Array.
Closes #11026
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 10 |
1 files changed, 10 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 168ce13097..d3704474a3 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -176,6 +176,16 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_raise(ActiveRecord::SubclassNotFound) { firm.companies.build(:type => "Account") } end + test "building the association with an array" do + speedometer = Speedometer.new(speedometer_id: "a") + data = [{name: "first"}, {name: "second"}] + speedometer.minivans.build(data) + + assert_equal 2, speedometer.minivans.size + assert speedometer.save + assert_equal ["first", "second"], speedometer.reload.minivans.map(&:name) + end + def test_association_keys_bypass_attribute_protection car = Car.create(:name => 'honda') |