-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return database connection into pool after configuration
When application code being loaded `has_closure_tree` method will get database connection implicitly and will not return it into the pool. In some circumstances this connection will not be available for request processing at runtime anymore.
- Loading branch information
Showing
3 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Configuration' do | ||
it 'returns connection to the pool after has_closure_tree setup' do | ||
class TypeDuplicate < ActiveRecord::Base | ||
self.table_name = "namespace_type#{table_name_suffix}" | ||
has_closure_tree | ||
end | ||
expect(ActiveRecord::Base.connection_pool.active_connection?).to be_nil | ||
end | ||
|
||
it 'returns connection to the pool after has_closure_tree setup with order' do | ||
class MetalDuplicate < ActiveRecord::Base | ||
self.table_name = "#{table_name_prefix}metal#{table_name_suffix}" | ||
has_closure_tree order: 'sort_order', name_column: 'value' | ||
end | ||
expect(ActiveRecord::Base.connection_pool.active_connection?).to be_nil | ||
end | ||
|
||
it 'returns connection to the pool after has_closure_tree_root setup' do | ||
class GroupDuplicate < ActiveRecord::Base | ||
self.table_name = "#{table_name_prefix}group#{table_name_suffix}" | ||
has_closure_tree_root :root_user | ||
end | ||
expect(ActiveRecord::Base.connection_pool.active_connection?).to be_nil | ||
end | ||
end |