aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-03-13 17:28:55 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-03-13 17:28:55 +0000
commit25fb2db409f30437d901bf644b7cdea39ce64fdb (patch)
tree49eb45a58db31704eb2574452ac83b6ebe637189 /activerecord/test
parent8ff44631939fd9220f03f9b18a687cbd040220e3 (diff)
downloadrails-25fb2db409f30437d901bf644b7cdea39ce64fdb.tar.gz
rails-25fb2db409f30437d901bf644b7cdea39ce64fdb.tar.bz2
rails-25fb2db409f30437d901bf644b7cdea39ce64fdb.zip
Dynamically set allow_concurrency. Closes #4044.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3862 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/method_scoping_test.rb6
-rw-r--r--activerecord/test/threaded_connections_test.rb10
2 files changed, 13 insertions, 3 deletions
diff --git a/activerecord/test/method_scoping_test.rb b/activerecord/test/method_scoping_test.rb
index 551d7c1dd3..c01aab6a36 100644
--- a/activerecord/test/method_scoping_test.rb
+++ b/activerecord/test/method_scoping_test.rb
@@ -9,7 +9,7 @@ class MethodScopingTest < Test::Unit::TestCase
def test_set_conditions
Developer.with_scope(:find => { :conditions => 'just a test...' }) do
- assert_equal 'just a test...', Thread.current[:scoped_methods][Developer][-1][:find][:conditions]
+ assert_equal 'just a test...', Developer.send(:current_scoped_methods)[:find][:conditions]
end
end
@@ -64,7 +64,7 @@ class MethodScopingTest < Test::Unit::TestCase
new_comment = nil
VerySpecialComment.with_scope(:create => { :post_id => 1 }) do
- assert_equal({ :post_id => 1 }, Thread.current[:scoped_methods][VerySpecialComment][-1][:create])
+ assert_equal({ :post_id => 1 }, VerySpecialComment.send(:current_scoped_methods)[:create])
new_comment = VerySpecialComment.create :body => "Wonderful world"
end
@@ -123,7 +123,7 @@ class NestedScopingTest < Test::Unit::TestCase
Developer.with_scope(:find => { :conditions => "name = 'David'" }) do
Developer.with_exclusive_scope(:find => { :conditions => "name = 'Jamis'" }) do
assert_equal({:find => { :conditions => "name = 'Jamis'" }}, Developer.instance_eval('current_scoped_methods'))
- assert_equal({:find => { :conditions => "name = 'Jamis'" }}, Thread.current[:scoped_methods][Developer][-1])
+ assert_equal({:find => { :conditions => "name = 'Jamis'" }}, Developer.send(:scoped_methods)[-1])
end
end
end
diff --git a/activerecord/test/threaded_connections_test.rb b/activerecord/test/threaded_connections_test.rb
index 177c6c7e13..d9cc47eef3 100644
--- a/activerecord/test/threaded_connections_test.rb
+++ b/activerecord/test/threaded_connections_test.rb
@@ -9,6 +9,16 @@ class ThreadedConnectionsTest < Test::Unit::TestCase
def setup
@connection = ActiveRecord::Base.remove_connection
@connections = []
+ @allow_concurrency = ActiveRecord::Base.allow_concurrency
+ end
+
+ def teardown
+ # clear the connection cache
+ ActiveRecord::Base.send(:clear_all_cached_connections!)
+ # set allow_concurrency to saved value
+ ActiveRecord::Base.allow_concurrency = @allow_concurrency
+ # reestablish old connection
+ ActiveRecord::Base.establish_connection(@connection)
end
def gather_connections(use_threaded_connections)