From c1ae7ec15ba01217d70e15da1b021c416097f3dd Mon Sep 17 00:00:00 2001
From: Arthur Neves <arthurnn@gmail.com>
Date: Wed, 4 May 2016 15:14:27 -0500
Subject: Test to swap connection at runtime

---
 activerecord/test/cases/multiple_db_test.rb | 7 +++++++
 1 file changed, 7 insertions(+)

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
-- 
cgit v1.2.3