diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-01-03 10:04:40 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-03 16:24:32 -0800 |
commit | 1313d386dacb580858e5951418a637f4e17cf5c1 (patch) | |
tree | 6f86a5613768a1f705fa89d4497d037914bdf60c /activerecord/test/cases | |
parent | 31d101879f1acae604d24d831a4b82a4482acf31 (diff) | |
download | rails-1313d386dacb580858e5951418a637f4e17cf5c1.tar.gz rails-1313d386dacb580858e5951418a637f4e17cf5c1.tar.bz2 rails-1313d386dacb580858e5951418a637f4e17cf5c1.zip |
Make Relation#create_with always merge rather than overwrite, not just when merging two relations. If you wish to overwrite, you can do relation.create_with(nil), or for a specific attribute, relation.create_with(:attr => nil).
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/relation_scoping_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb index 7c6899d438..bff0151f1a 100644 --- a/activerecord/test/cases/relation_scoping_test.rb +++ b/activerecord/test/cases/relation_scoping_test.rb @@ -491,5 +491,15 @@ class DefaultScopingTest < ActiveRecord::TestCase PoorDeveloperCalledJamis.create_with(:name => 'Aaron')).new assert_equal 20, aaron.salary assert_equal 'Aaron', aaron.name + + aaron = PoorDeveloperCalledJamis.create_with(:name => 'foo', :salary => 20). + create_with(:name => 'Aaron').new + assert_equal 20, aaron.salary + assert_equal 'Aaron', aaron.name + end + + def test_create_with_reset + jamis = PoorDeveloperCalledJamis.create_with(:name => 'Aaron').create_with(nil).new + assert_equal 'Jamis', jamis.name end end |