File tree Expand file tree Collapse file tree 4 files changed +12
-21
lines changed
Expand file tree Collapse file tree 4 files changed +12
-21
lines changed Original file line number Diff line number Diff line change 1111jobs :
1212 test :
1313 runs-on : ubuntu-latest
14+ env :
15+ RAILS_VERSION : ${{ matrix.rails }}
16+ RAILS_ENV : test
17+ DATABASE_URL_PG : postgres://postgres:postgres@127.0.0.1:5432/closure_tree_test
18+ DATABASE_URL_MYSQL : mysql2://root:root@127.0.0.1:3306/closure_tree_test
19+ DATABASE_URL_SQLITE3 : ' sqlite3::memory:'
20+ WITH_ADVISORY_LOCK_PREFIX : ${{ github.run_id }}
1421
1522 services :
1623 postgres :
4653 ruby :
4754 - ' 3.4'
4855 rails :
56+ - ' 7.2'
4957 - ' 8.0'
5058 - ' 8.1.1'
5159
@@ -59,26 +67,12 @@ jobs:
5967 ruby-version : ${{ matrix.ruby }}
6068 bundler-cache : true
6169 rubygems : latest
62- env :
63- RAILS_VERSION : ${{ matrix.rails }}
64- BUNDLE_GEMFILE : ${{ github.workspace }}/Gemfile
6570
6671 - name : Setup databases
67- env :
68- RAILS_ENV : test
69- DATABASE_URL_PG : postgres://postgres:postgres@127.0.0.1:5432/closure_tree_test
70- DATABASE_URL_MYSQL : mysql2://root:root@127.0.0.1:3306/closure_tree_test
71- DATABASE_URL_SQLITE3 : ' sqlite3::memory:'
7272 run : |
7373 cd test/dummy
7474 bundle exec rails db:setup_all
7575
7676 - name : Run tests
77- env :
78- RAILS_ENV : test
79- DATABASE_URL_PG : postgres://postgres:postgres@127.0.0.1:5432/closure_tree_test
80- DATABASE_URL_MYSQL : mysql2://root:root@127.0.0.1:3306/closure_tree_test
81- DATABASE_URL_SQLITE3 : ' sqlite3::memory:'
82- WITH_ADVISORY_LOCK_PREFIX : ${{ github.run_id }}
8377 run : |
84- bundle exec rake test
78+ bundle exec rake test
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ def build_hierarchy_delete_query(hierarchy_table, id)
8484 # This ensures proper quoting for the specific database adapter (MySQL uses backticks, PostgreSQL uses double quotes)
8585 def to_sql_with_connection ( arel_manager )
8686 collector = Arel ::Collectors ::SQLString . new
87- visitor = connection . send ( :arel_visitor )
87+ visitor = connection . visitor
8888 visitor . accept ( arel_manager . ast , collector ) . value
8989 end
9090 end
Original file line number Diff line number Diff line change @@ -52,14 +52,14 @@ def _ct_after_save
5252
5353 def _ct_before_destroy
5454 _ct . with_advisory_lock do
55- adopt_children_to_grandparent if _ct . options [ :dependent ] == :adopt
55+ _ct_adopt_children_to_grandparent if _ct . options [ :dependent ] == :adopt
5656 delete_hierarchy_references
5757 self . class . find ( id ) . children . find_each ( &:rebuild! ) if _ct . options [ :dependent ] == :nullify
5858 end
5959 true # don't prevent destruction
6060 end
6161
62- def adopt_children_to_grandparent
62+ private def _ct_adopt_children_to_grandparent
6363 grandparent_id = read_attribute ( _ct . parent_column_name )
6464 children_ids = self . class . where ( _ct . parent_column_name => id ) . pluck ( :id )
6565
Original file line number Diff line number Diff line change @@ -60,8 +60,6 @@ def run_adopt_tests_for(model_class)
6060 assert_equal p2 , p3 . parent
6161
6262 hierarchy = model_class . hierarchy_class
63- hierarchy . where ( ancestor_id : p2 . id ) . count
64- hierarchy . where ( descendant_id : p3 . id ) . count
6563
6664 # Destroy p1 (root node)
6765 p1 . destroy
@@ -210,7 +208,6 @@ def run_adopt_tests_for(model_class)
210208 leaf = model_class . create! ( name : 'leaf' , parent : p2 )
211209
212210 hierarchy = model_class . hierarchy_class
213- hierarchy . count
214211
215212 # Destroy leaf (has no children)
216213 leaf . destroy
You can’t perform that action at this time.
0 commit comments