aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-09-17 16:26:35 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-09-17 16:26:35 -0300
commitafa47805720bd7f315536fc08d5360a514cb2422 (patch)
tree74d29f6110cd50c2e200e28b0d014733a99320c4 /activerecord/test
parent3fd016b2dc9950670c33fa6a5d31bb215f705a50 (diff)
parent93717f39b7a59569b3ae5ed09d1cf782aec764f2 (diff)
downloadrails-afa47805720bd7f315536fc08d5360a514cb2422.tar.gz
rails-afa47805720bd7f315536fc08d5360a514cb2422.tar.bz2
rails-afa47805720bd7f315536fc08d5360a514cb2422.zip
Merge pull request #16875 from alan/dont_autosave_has_one_through_record
Don't autosave unchanged has_one through records Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/autosave_association_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index 025cdbeba9..b2a7d3956d 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -19,6 +19,9 @@ require 'models/treasure'
require 'models/eye'
require 'models/electron'
require 'models/molecule'
+require 'models/member'
+require 'models/member_detail'
+require 'models/organization'
class TestAutosaveAssociationsInGeneral < ActiveRecord::TestCase
def test_autosave_validation
@@ -1116,6 +1119,27 @@ class TestAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase
end
end
+class TestAutosaveAssociationOnAHasOneThroughAssociation < ActiveRecord::TestCase
+ self.use_transactional_fixtures = false unless supports_savepoints?
+
+ def setup
+ super
+ organization = Organization.create
+ @member = Member.create
+ MemberDetail.create(organization: organization, member: @member)
+ end
+
+ def test_should_not_has_one_through_model
+ class << @member.organization
+ def save(*args)
+ super
+ raise 'Oh noes!'
+ end
+ end
+ assert_nothing_raised { @member.save }
+ end
+end
+
class TestAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase
self.use_transactional_fixtures = false unless supports_savepoints?