diff options
author | Xavier Noria <fxn@hashref.com> | 2010-10-22 10:28:53 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-10-22 10:28:53 +0200 |
commit | 5b86c3e5bb2bb54003d8f211b46a7b992355dbf5 (patch) | |
tree | 1375ec5b4b1bfc68b8255b82980aa6bb45b6da3b /activerecord/test/cases | |
parent | fc8c0729881fff59e916f7ab180dbfa03ee1b891 (diff) | |
download | rails-5b86c3e5bb2bb54003d8f211b46a7b992355dbf5.tar.gz rails-5b86c3e5bb2bb54003d8f211b46a7b992355dbf5.tar.bz2 rails-5b86c3e5bb2bb54003d8f211b46a7b992355dbf5.zip |
has_one maintains the association with separate after_create/after_update
This way parent models can get their own after_create and
after_update callbacks fired after has_one has done its job.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/autosave_association_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index 52382f5afc..89be94c81f 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -17,6 +17,7 @@ require 'models/tag' require 'models/tagging' require 'models/treasure' require 'models/company' +require 'models/eye' class TestAutosaveAssociationsInGeneral < ActiveRecord::TestCase def test_autosave_should_be_a_valid_option_for_has_one @@ -170,6 +171,25 @@ class TestDefaultAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCas firm.account = Account.find(:first).clone assert_queries(2) { firm.save! } end + + def test_callbacks_firing_order_on_create + eye = Eye.create(:iris_attributes => {:color => 'honey'}) + assert_equal [true, false], eye.after_create_callbacks_stack + end + + def test_callbacks_firing_order_on_update + eye = Eye.create(:iris_attributes => {:color => 'honey'}) + eye.update_attributes(:iris_attributes => {:color => 'green'}) + assert_equal [true, false], eye.after_update_callbacks_stack + end + + def test_callbacks_firing_order_on_save + eye = Eye.create(:iris_attributes => {:color => 'honey'}) + assert_equal [false, false], eye.after_save_callbacks_stack + + eye.update_attributes(:iris_attributes => {:color => 'blue'}) + assert_equal [false, false, false, false], eye.after_save_callbacks_stack + end end class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase |