diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..6a801e3a --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @get-bridge/arcanine diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..01928f1d --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,29 @@ +#### JIRA + +#### Changes + +- + +#### Checklist +- [ ] Feature Flag Required +- [ ] Bug + +#### Test plan + +- [ ] Walk-through +- [ ] Peer review +- [ ] Inspection + - Detailed steps and prerequisites for validating the change: + - + +#### Risk Analysis - the risk of change is evaluated + +- [ ] Low - Majority of the changes are low risk which doesn’t require extra testing, only code review by 1 reviewer + - [ ] 1 reviewer +- [ ] Medium - Some portion of changes are medium risk which need peer testing and review by 2 reviewers + - [ ] 2 reviewers + - [ ] peer testing +- [ ] High - A very few breaking changes are high risk and need very throughout testing and review and also coordinated release process. + - [ ] 2 reviewers + - [ ] peer testing + - [ ] coordinated release diff --git a/lib/closure_tree/has_closure_tree.rb b/lib/closure_tree/has_closure_tree.rb index b0bc5b1a..6fb47d7a 100644 --- a/lib/closure_tree/has_closure_tree.rb +++ b/lib/closure_tree/has_closure_tree.rb @@ -14,25 +14,25 @@ def has_closure_tree(options = {}) :with_advisory_lock ) - class_attribute :_ct - self._ct = ClosureTree::Support.new(self, options) + connection_pool.with_connection { + class_attribute :_ct + self._ct = ClosureTree::Support.new(self, options) - # Auto-inject the hierarchy table - # See https://github.com/patshaughnessy/class_factory/blob/master/lib/class_factory/class_factory.rb - class_attribute :hierarchy_class - self.hierarchy_class = _ct.hierarchy_class_for_model + # Auto-inject the hierarchy table + # See https://github.com/patshaughnessy/class_factory/blob/master/lib/class_factory/class_factory.rb + class_attribute :hierarchy_class + self.hierarchy_class = _ct.hierarchy_class_for_model - # tests fail if you include Model before HierarchyMaintenance wtf - include ClosureTree::HierarchyMaintenance - include ClosureTree::Model - include ClosureTree::Finders - include ClosureTree::HashTree - include ClosureTree::Digraphs + # tests fail if you include Model before HierarchyMaintenance wtf + include ClosureTree::HierarchyMaintenance + include ClosureTree::Model + include ClosureTree::Finders + include ClosureTree::HashTree + include ClosureTree::Digraphs - include ClosureTree::DeterministicOrdering if _ct.order_option? - include ClosureTree::NumericDeterministicOrdering if _ct.order_is_numeric? - - connection_pool.release_connection + include ClosureTree::DeterministicOrdering if _ct.order_option? + include ClosureTree::NumericDeterministicOrdering if _ct.order_is_numeric? + } rescue StandardError => e raise e unless ClosureTree.configuration.database_less end diff --git a/lib/closure_tree/hierarchy_maintenance.rb b/lib/closure_tree/hierarchy_maintenance.rb index e3f4ee46..fce9e3e6 100644 --- a/lib/closure_tree/hierarchy_maintenance.rb +++ b/lib/closure_tree/hierarchy_maintenance.rb @@ -123,7 +123,7 @@ def cleanup! [:descendant_id, :ancestor_id].each do |foreign_key| alias_name = foreign_key.to_s.split('_').first + "s" - alias_table = Arel::Table.new(table_name).alias(alias_name) + alias_table = Arel::Table.new(table_name, type_caster: type_caster).alias(alias_name) arel_join = hierarchy_table.join(alias_table, Arel::Nodes::OuterJoin) .on(alias_table[primary_key].eq(hierarchy_table[foreign_key])) .join_sources diff --git a/spec/pool_spec.rb b/spec/pool_spec.rb index de25c4fb..89d4e066 100644 --- a/spec/pool_spec.rb +++ b/spec/pool_spec.rb @@ -1,6 +1,11 @@ require 'spec_helper' describe 'Configuration' do + before(:each) do + # Make sure we start up with no active connection + ActiveRecord::Base.connection_pool.release_connection + end + it 'returns connection to the pool after has_closure_tree setup' do class TypeDuplicate < ActiveRecord::Base self.table_name = "namespace_type#{table_name_suffix}"