diff options
author | Arthur Neves <arthurnn@gmail.com> | 2016-05-11 08:04:26 -0400 |
---|---|---|
committer | Arthur Neves <arthurnn@gmail.com> | 2016-05-11 08:04:26 -0400 |
commit | f1030fd897640f2d051ee29143544fad5b64d6d3 (patch) | |
tree | d8f9ceea12df8d7078a535544318f6098aa98135 /activerecord/test | |
parent | 525fa7ef7ce02bf3bfd99058ea18547f21c4f715 (diff) | |
download | rails-f1030fd897640f2d051ee29143544fad5b64d6d3.tar.gz rails-f1030fd897640f2d051ee29143544fad5b64d6d3.tar.bz2 rails-f1030fd897640f2d051ee29143544fad5b64d6d3.zip |
Dont cache the conn_spec_name when empty
We cannot cache the connection_specification_name when it doesnt
exist. Thats because the parent value could change, and we should keep
failling back to the parent. If we cache that in a children as an ivar,
we would not fallback anymore in the next call, so the children would
not get the new parent spec_name.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/connection_adapters/connection_handler_test.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/test/cases/connection_adapters/connection_handler_test.rb b/activerecord/test/cases/connection_adapters/connection_handler_test.rb index 62beb8bea4..2d3c411479 100644 --- a/activerecord/test/cases/connection_adapters/connection_handler_test.rb +++ b/activerecord/test/cases/connection_adapters/connection_handler_test.rb @@ -91,7 +91,7 @@ module ActiveRecord end def test_a_class_using_custom_pool_and_switching_back_to_primary - klass2 = Class.new(Base) { def self.name; 'klass2'; end } + klass2 = Class.new(Base) { def self.name; 'klass2'; end } assert_equal klass2.connection.object_id, ActiveRecord::Base.connection.object_id @@ -103,6 +103,15 @@ module ActiveRecord assert_equal klass2.connection.object_id, ActiveRecord::Base.connection.object_id end + + def test_connection_specification_name_should_fallback_to_parent + klassA = Class.new(Base) + klassB = Class.new(klassA) + + assert_equal klassB.connection_specification_name, klassA.connection_specification_name + klassA.connection_specification_name = "readonly" + assert_equal "readonly", klassB.connection_specification_name + end end end end |