diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-10-24 22:37:29 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-10-24 22:37:29 -0200 |
commit | 7160ffbe59ef99f01f530ad6e8377f8a91218396 (patch) | |
tree | 83da2b43c2d3bf7a6ed329f33b420f75e132c69d /activerecord/test/cases | |
parent | a53f7167061a2128ed256593845a456f4c717dfe (diff) | |
parent | 8022fc4913d5fa285889795617a1f37c5aa705a9 (diff) | |
download | rails-7160ffbe59ef99f01f530ad6e8377f8a91218396.tar.gz rails-7160ffbe59ef99f01f530ad6e8377f8a91218396.tar.bz2 rails-7160ffbe59ef99f01f530ad6e8377f8a91218396.zip |
Merge pull request #12621 from laurocaetano/fix_has_one_association_with_primary_key_set
Save association when primary key is manually set
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/has_one_associations_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb index 9cd4db8dc9..cdd386187b 100644 --- a/activerecord/test/cases/associations/has_one_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_associations_test.rb @@ -524,4 +524,15 @@ class HasOneAssociationsTest < ActiveRecord::TestCase assert_equal 'new name', pirate.ship.reload.name end + def test_has_one_autosave_with_primary_key_manually_set + post = Post.create(id: 1234, title: "Some title", body: 'Some content') + author = Author.new(id: 33, name: 'Hank Moody') + + author.post = post + author.save + author.reload + + assert_not_nil author.post + assert_equal author.post, post + end end |