diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-02-26 09:47:33 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-02-26 09:47:33 -0800 |
commit | fcf8d6e40f516de30dd6805f5a988e4c20701878 (patch) | |
tree | 3f88586fff65fffde8eaa2f8ba45eeac7312f5a7 /activerecord/test/cases/timestamp_test.rb | |
parent | e24e086ef1de73beffc0870cb37d6ae42cbbd2c8 (diff) | |
parent | dce4383319d8fcccc26d12fc0bbd4b19a149ee41 (diff) | |
download | rails-fcf8d6e40f516de30dd6805f5a988e4c20701878.tar.gz rails-fcf8d6e40f516de30dd6805f5a988e4c20701878.tar.bz2 rails-fcf8d6e40f516de30dd6805f5a988e4c20701878.zip |
Merge pull request #9443 from exviva/belongs_to_touch_new_record
Fix touching an invalid parent record for belongs_to
Diffstat (limited to 'activerecord/test/cases/timestamp_test.rb')
-rw-r--r-- | activerecord/test/cases/timestamp_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index bb034848e1..777a2b70dd 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -113,6 +113,18 @@ class TimestampTest < ActiveRecord::TestCase assert_not_equal previously_owner_updated_at, pet.owner.updated_at end + def test_saving_a_new_record_belonging_to_invalid_parent_with_touch_should_not_raise_exception + klass = Class.new(Owner) do + def self.name; 'Owner'; end + validate { errors.add(:base, :invalid) } + end + + pet = Pet.new(owner: klass.new) + pet.save! + + assert pet.owner.new_record? + end + def test_saving_a_record_with_a_belongs_to_that_specifies_touching_a_specific_attribute_the_parent_should_update_that_attribute klass = Class.new(ActiveRecord::Base) do def self.name; 'Pet'; end |