diff options
author | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-09-20 21:59:49 +0200 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-09-23 20:32:01 +0200 |
commit | 70b8ea4fa6f432919340345ae0d5af6aa8f87ec8 (patch) | |
tree | d23147412f49339d8671b9933ca0a5528f9313ca /activerecord/test | |
parent | 2e75bd0808f4dcac328b690aaad176cbfe96773e (diff) | |
download | rails-70b8ea4fa6f432919340345ae0d5af6aa8f87ec8.tar.gz rails-70b8ea4fa6f432919340345ae0d5af6aa8f87ec8.tar.bz2 rails-70b8ea4fa6f432919340345ae0d5af6aa8f87ec8.zip |
Make AssociationCollection start transactions in the correct database.
AssociationCollection now starts transactions by calling
AssociationCollection#transaction instead of @owner.transaction or
@reflection.klass.transaction.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1081 state:committed]
Diffstat (limited to 'activerecord/test')
3 files changed, 27 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index c1d4ea8b50..2949f1d304 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -738,4 +738,13 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase # Array#count in Ruby >=1.8.7, which would raise an ArgumentError assert_nothing_raised { david.projects.count(:all, :conditions => '1=1') } end + + uses_mocha 'mocking Post.transaction' do + def test_association_proxy_transaction_method_starts_transaction_in_association_class + Post.expects(:transaction) + Category.find(:first).posts.transaction do + # nothing + end + end + end end diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 9d550916d7..315d77de07 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -1071,4 +1071,13 @@ class HasManyAssociationsTest < ActiveRecord::TestCase ActiveRecord::Base.store_full_sti_class = old end + uses_mocha 'mocking Comment.transaction' do + def test_association_proxy_transaction_method_starts_transaction_in_association_class + Comment.expects(:transaction) + Post.find(:first).comments.transaction do + # nothing + end + end + end + end diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 0be050ec81..12cce98c26 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -220,4 +220,13 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase assert_equal [posts(:welcome).id, posts(:authorless).id].sort, person.post_ids.sort assert !person.posts.loaded? end + + uses_mocha 'mocking Tag.transaction' do + def test_association_proxy_transaction_method_starts_transaction_in_association_class + Tag.expects(:transaction) + Post.find(:first).tags.transaction do + # nothing + end + end + end end |