diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-10 11:41:55 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-10 11:41:55 -0300 |
commit | 6e3ab3e15faf782f6a937ccf5574a4fb63e3e353 (patch) | |
tree | 5a4798cd67b536acaa6e29f2234b4a12df7c1b02 /activerecord/test/cases | |
parent | 39e07b64ce3f4bb55e60ba0266e677f8e4f4893a (diff) | |
parent | f74a5616e89f03e13a025401475ac1101bb159ae (diff) | |
download | rails-6e3ab3e15faf782f6a937ccf5574a4fb63e3e353.tar.gz rails-6e3ab3e15faf782f6a937ccf5574a4fb63e3e353.tar.bz2 rails-6e3ab3e15faf782f6a937ccf5574a4fb63e3e353.zip |
Merge pull request #8313 from alan/only_save_changed_has_one_objects
Save has_one associations only if record has changes
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/autosave_association_test.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index f7584c3a51..8e3825999d 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -683,10 +683,25 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase end end + @ship.pirate.catchphrase = "Changed Catchphrase" + assert_raise(RuntimeError) { assert !@pirate.save } assert_not_nil @pirate.reload.ship end + def test_should_save_changed_has_one_changed_object_if_child_is_saved + @pirate.ship.name = "NewName" + @pirate.ship.expects(:save).once.returns(true) + + assert @pirate.save + end + + def test_should_not_save_changed_has_one_unchanged_object_if_child_is_saved + @pirate.ship.expects(:save).never + + assert @pirate.save + end + # belongs_to def test_should_destroy_a_parent_association_as_part_of_the_save_transaction_if_it_was_marked_for_destroyal assert !@ship.pirate.marked_for_destruction? |