aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2016-05-04 15:14:27 -0500
committerArthur Neves <arthurnn@gmail.com>2016-05-05 15:29:11 -0500
commitc1ae7ec15ba01217d70e15da1b021c416097f3dd (patch)
tree58d3cf521f9d349f10df0b166317c3ea83fc3fbd /activerecord
parent9872905336172df4f70cab9682b397b59deac1b8 (diff)
downloadrails-c1ae7ec15ba01217d70e15da1b021c416097f3dd.tar.gz
rails-c1ae7ec15ba01217d70e15da1b021c416097f3dd.tar.bz2
rails-c1ae7ec15ba01217d70e15da1b021c416097f3dd.zip
Test to swap connection at runtime
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/multiple_db_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/multiple_db_test.rb b/activerecord/test/cases/multiple_db_test.rb
index e20ce20599..b7fc8710ca 100644
--- a/activerecord/test/cases/multiple_db_test.rb
+++ b/activerecord/test/cases/multiple_db_test.rb
@@ -24,6 +24,13 @@ class MultipleDbTest < ActiveRecord::TestCase
assert_equal(ActiveRecord::Base.connection, Entrant.connection)
end
+ def test_swapping_the_connection
+ old_spec_id, Course.specification_id = Course.specification_id, "primary"
+ assert_equal(Entrant.connection, Course.connection)
+ ensure
+ Course.specification_id = old_spec_id
+ end
+
def test_find
c1 = Course.find(1)
assert_equal "Ruby Development", c1.name