aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-11-16 12:43:59 -0600
committerSean Griffin <sean@seantheprogrammer.com>2015-11-16 12:43:59 -0600
commitbde974f418e2de7095fd6fd19c1e72b0c749fc30 (patch)
tree36beb89e311913c8619b03d3e0da2afcbe3e1804 /activerecord/test/cases
parent0f78936eac10f49e787658642ffec0b4abe6c9ef (diff)
parent817c1825c15013fd0180762ac5c05a2e024a640d (diff)
downloadrails-bde974f418e2de7095fd6fd19c1e72b0c749fc30.tar.gz
rails-bde974f418e2de7095fd6fd19c1e72b0c749fc30.tar.bz2
rails-bde974f418e2de7095fd6fd19c1e72b0c749fc30.zip
Merge pull request #22300 from yui-knk/fix_21893
Except keys of `build_record`'s argument from `create_scope` in initiā€¦
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index eb94870a35..50ca6537cc 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -203,9 +203,22 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
bulb = car.bulbs.create
assert_equal 'defaulty', bulb.name
+ end
+
+ def test_build_and_create_from_association_should_respect_passed_attributes_over_default_scope
+ car = Car.create(name: 'honda')
+
+ bulb = car.bulbs.build(name: 'exotic')
+ assert_equal 'exotic', bulb.name
- bulb = car.bulbs.create(:name => 'exotic')
+ bulb = car.bulbs.create(name: 'exotic')
assert_equal 'exotic', bulb.name
+
+ bulb = car.awesome_bulbs.build(frickinawesome: false)
+ assert_equal false, bulb.frickinawesome
+
+ bulb = car.awesome_bulbs.create(frickinawesome: false)
+ assert_equal false, bulb.frickinawesome
end
def test_build_from_association_should_respect_scope