From 8022fc4913d5fa285889795617a1f37c5aa705a9 Mon Sep 17 00:00:00 2001 From: laurocaetano Date: Thu, 24 Oct 2013 00:06:49 -0200 Subject: Save association when primary key is manually set --- .../test/cases/associations/has_one_associations_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activerecord/test') 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 -- cgit v1.2.3