diff options
Diffstat (limited to 'activerecord/test/cases/multiple_db_test.rb')
-rw-r--r-- | activerecord/test/cases/multiple_db_test.rb | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/activerecord/test/cases/multiple_db_test.rb b/activerecord/test/cases/multiple_db_test.rb index 39cdcf5403..e3bb51bd77 100644 --- a/activerecord/test/cases/multiple_db_test.rb +++ b/activerecord/test/cases/multiple_db_test.rb @@ -1,7 +1,7 @@ require "cases/helper" -require 'models/entrant' -require 'models/bird' -require 'models/course' +require "models/entrant" +require "models/bird" +require "models/course" class MultipleDbTest < ActiveRecord::TestCase self.use_transactional_tests = false @@ -24,6 +24,13 @@ class MultipleDbTest < ActiveRecord::TestCase assert_equal(ActiveRecord::Base.connection, Entrant.connection) end + def test_swapping_the_connection + old_spec_name, Course.connection_specification_name = Course.connection_specification_name, "primary" + assert_equal(Entrant.connection, Course.connection) + ensure + Course.connection_specification_name = old_spec_name + end + def test_find c1 = Course.find(1) assert_equal "Ruby Development", c1.name @@ -53,7 +60,7 @@ class MultipleDbTest < ActiveRecord::TestCase ActiveSupport::Dependencies.clear Object.send(:remove_const, :Course) - require_dependency 'models/course' + require_dependency "models/course" assert Course.connection end @@ -89,8 +96,8 @@ class MultipleDbTest < ActiveRecord::TestCase end def test_connection - assert_equal Entrant.arel_engine.connection, Bird.arel_engine.connection - assert_not_equal Entrant.arel_engine.connection, Course.arel_engine.connection + assert_equal Entrant.arel_engine.connection.object_id, Bird.arel_engine.connection.object_id + assert_not_equal Entrant.arel_engine.connection.object_id, Course.arel_engine.connection.object_id end unless in_memory_db? @@ -104,7 +111,7 @@ class MultipleDbTest < ActiveRecord::TestCase def test_associations_should_work_when_model_has_no_connection begin ActiveRecord::Base.remove_connection - assert_nothing_raised ActiveRecord::ConnectionNotEstablished do + assert_nothing_raised do College.first.courses.first end ensure |