Skip to content

Commit f8f76d8

Browse files
committed
ActiveRecord 7.2 support
1 parent 583ed2b commit f8f76d8

23 files changed

+82
-109
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,11 @@ jobs:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2']
23-
gemfile: [ar_52, ar_60, ar_61, ar_70, ar_next]
24-
exclude:
25-
- ruby-version: '3.2'
26-
gemfile: ar_52
27-
- ruby-version: '3.2'
28-
gemfile: ar_60
29-
- ruby-version: '3.2'
30-
gemfile: ar_61
31-
- ruby-version: '3.1'
32-
gemfile: ar_52
33-
- ruby-version: '3.1'
34-
gemfile: ar_60
35-
- ruby-version: '3.1'
36-
gemfile: ar_61
37-
- ruby-version: '3.0'
38-
gemfile: ar_52
39-
- ruby-version: '2.6'
40-
gemfile: ar_next
41-
- ruby-version: '2.6'
42-
gemfile: ar_70
43-
- ruby-version: '2.5'
44-
gemfile: ar_next
45-
- ruby-version: '2.5'
46-
gemfile: ar_70
22+
ruby-version: ['3.1', '3.2', '3.3']
23+
gemfile: [ar_70, ar_71, ar_72, ar_next]
24+
# exclude:
25+
# - ruby-version: '3.2'
26+
# gemfile: ar_60
4727
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
4828
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
4929
steps:

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ jobs:
1818

1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v3
2222
- name: Set up Ruby
2323
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
2424
# change this to (see https://github.com/ruby/setup-ruby#versioning):
2525
uses: ruby/setup-ruby@v1
2626
# uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
2727
with:
28-
ruby-version: 2.7
28+
ruby-version: 3.1
2929
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
3030
- name: Run rubocop
3131
run: bundle exec rubocop

.github/workflows/rubygem.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ jobs:
1818
contents: read
1919

2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v3
2222
- name: Set up Ruby
2323
uses: ruby/setup-ruby@v1
2424
with:
25-
ruby-version: 2.7
25+
ruby-version: 3.1
2626
- run: bundle install
2727
- name: Publish to RubyGems
2828
env:

.rubocop.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ require:
55
inherit_from: .rubocop_todo.yml
66

77
AllCops:
8-
TargetRubyVersion: 2.5
8+
TargetRubyVersion: 3.1
99
NewCops: enable
1010
SuggestExtensions: false
1111

12+
Gemspec/DevelopmentDependencies:
13+
EnforcedStyle: gemspec
14+
1215
Gemspec/RequireMFA:
1316
Enabled: false
1417

@@ -24,6 +27,9 @@ RSpec/NestedGroups:
2427
Style/Alias:
2528
EnforcedStyle: prefer_alias
2629

30+
Style/Documentation:
31+
Enabled: false
32+
2733
Style/FrozenStringLiteralComment:
2834
Exclude:
2935
- 'gemfiles/**/*'

Appraisals

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
# frozen_string_literal: true
22

3-
appraise 'ar-52' do
4-
gem 'activerecord', '~> 5.2.0'
5-
gem 'activesupport', '~> 5.2.0'
6-
end
7-
8-
appraise 'ar-60' do
9-
gem 'activerecord', '~> 6.0.0'
10-
gem 'activesupport', '~> 6.0.0'
3+
appraise 'ar-70' do
4+
gem 'activerecord', '~> 7.0'
5+
gem 'activesupport', '~> 7.0'
116
end
127

13-
appraise 'ar-61' do
14-
gem 'activerecord', '~> 6.1.0'
15-
gem 'activesupport', '~> 6.1.0'
8+
appraise 'ar-71' do
9+
gem 'activerecord', '~> 7.1'
10+
gem 'activesupport', '~> 7.1'
1611
end
1712

18-
appraise 'ar-70' do
19-
gem 'activerecord', '~> 7.0'
20-
gem 'activesupport', '~> 7.0'
13+
appraise 'ar-72' do
14+
gem 'activerecord', '~> 7.2'
15+
gem 'activesupport', '~> 7.2'
2116
end
2217

2318
appraise 'ar-next' do

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### Version 4.0.0
2+
- ADD: Support for Rails 7.2
3+
- BREAKING: Dropped support for Rails < 7
4+
- BREAKING: Dropped support old Rubies < 3.1
5+
16
### Version 3.5.0
27
- Added :dependent option for setting explicit deletion behaviour (issue #31)
38
- Added automatic cycle detection when supported (currently only PostgresSQL 14+) (issue #22)

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,16 @@ Luckily, there is already a SQL standard that makes it very easy to retrieve dat
1414

1515
## Supported environments
1616
ActsAsRecursiveTree currently supports following ActiveRecord versions and is tested for compatibility:
17-
* ActiveRecord 5.2.x
18-
* ActiveRecord 6.0.x
19-
* ActiveRecord 6.1.x
2017
* ActiveRecord 7.0.x
2118
* ActiveRecord 7.1.x
19+
* ActiveRecord 7.2.x
20+
* ActiveRecord NEXT (from git)
2221

2322
## Supported Rubies
2423
ActsAsRecursiveTree is tested with following rubies:
25-
* MRuby 2.5
26-
* MRuby 2.6
27-
* MRuby 2.7
28-
* MRuby 3.0
2924
* MRuby 3.1
3025
* MRuby 3.2
26+
* MRuby 3.3
3127

3228
Other Ruby implementations are not tested, but should also work.
3329

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ task default: [:spec]
1010
desc 'Deletes temporary files'
1111
task :clean_tmp_files do
1212
%w[db.log test.sqlite3].each do |file|
13-
File.delete(file) if File.exist?(file)
13+
FileUtils.rm_f(file)
1414
end
1515
end

acts_as_recursive_tree.gemspec

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,21 @@ Gem::Specification.new do |spec|
1818
'bug_tracker_uri' => 'https://github.com/1and1/acts_as_recursive_tree/issues',
1919
'changelog_uri' => 'https://github.com/1and1/acts_as_recursive_tree/blob/main/CHANGELOG.md'
2020
}
21-
spec.required_ruby_version = '>= 2.5.0'
21+
spec.required_ruby_version = '>= 3.1.0'
2222
spec.files = `git ls-files -z`.split("\x0")
23-
spec.test_files = spec.files.grep(%r{^spec/})
2423
spec.require_paths = ['lib']
2524

26-
spec.add_runtime_dependency 'activerecord', '>= 5.2.0', '< 8'
27-
spec.add_runtime_dependency 'activesupport', '>= 5.2.0', '< 8'
28-
spec.add_runtime_dependency 'zeitwerk', '>= 2.4'
25+
spec.add_dependency 'activerecord', '>= 7.0.0', '< 8'
26+
spec.add_dependency 'activesupport', '>= 7.0.0', '< 8'
27+
spec.add_dependency 'zeitwerk', '>= 2.4'
2928

30-
spec.add_development_dependency 'appraisal', '~> 2.4'
31-
spec.add_development_dependency 'database_cleaner-active_record', '~> 2.1'
29+
spec.add_development_dependency 'appraisal', '~> 2.5'
30+
spec.add_development_dependency 'database_cleaner-active_record', '~> 2.2'
3231
spec.add_development_dependency 'rake'
33-
spec.add_development_dependency 'rspec-rails', '>= 3.5'
34-
spec.add_development_dependency 'rubocop', '~> 1.23.0'
35-
spec.add_development_dependency 'rubocop-rails', '~> 2.12.0'
36-
spec.add_development_dependency 'rubocop-rspec', '~> 2.6.0'
32+
spec.add_development_dependency 'rspec-rails', '>= 6.1'
33+
spec.add_development_dependency 'rubocop', '~> 1.66.0'
34+
spec.add_development_dependency 'rubocop-rails', '~> 2.26.0'
35+
spec.add_development_dependency 'rubocop-rspec', '~> 3.0.4'
3736

38-
spec.add_development_dependency 'sqlite3', '~> 1.3'
37+
spec.add_development_dependency 'sqlite3', '~> 2.0'
3938
end

gemfiles/ar_61.gemfile

Lines changed: 0 additions & 8 deletions
This file was deleted.

gemfiles/ar_52.gemfile renamed to gemfiles/ar_71.gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "https://rubygems.org"
44

5-
gem "activerecord", "~> 5.2.0"
6-
gem "activesupport", "~> 5.2.0"
5+
gem "activerecord", "~> 7.1"
6+
gem "activesupport", "~> 7.1"
77

88
gemspec path: "../"

gemfiles/ar_60.gemfile renamed to gemfiles/ar_72.gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "https://rubygems.org"
44

5-
gem "activerecord", "~> 6.0.0"
6-
gem "activesupport", "~> 6.0.0"
5+
gem "activerecord", "~> 7.2"
6+
gem "activesupport", "~> 7.2"
77

88
gemspec path: "../"

lib/acts_as_recursive_tree/acts_macro.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def recursive_tree(parent_key: :parent_id, parent_type_column: nil, dependent: n
1414
model_class: self,
1515
parent_key: parent_key.to_sym,
1616
parent_type_column: parent_type_column.try(:to_sym),
17-
dependent: dependent
17+
dependent:
1818
)
1919

2020
include ActsAsRecursiveTree::Model

lib/acts_as_recursive_tree/builders/ancestors.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Builders
55
class Ancestors < RelationBuilder
66
self.traversal_strategy = ActsAsRecursiveTree::Builders::Strategies::Ancestor
77

8-
def get_query_options(&block)
8+
def get_query_options(&)
99
opts = super
1010
opts.ensure_ordering!
1111
opts

lib/acts_as_recursive_tree/builders/leaves.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def create_select_manger(column = nil)
1616
select_manager
1717
end
1818

19-
def get_query_options(&_block)
19+
def get_query_options(&)
2020
# do not allow any custom options
2121
ActsAsRecursiveTree::Options::QueryOptions.new
2222
end

lib/acts_as_recursive_tree/builders/relation_builder.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Builders
99
#
1010
class RelationBuilder
1111
def self.build(klass, ids, exclude_ids: false, &block)
12-
new(klass, ids, exclude_ids: exclude_ids, &block).build
12+
new(klass, ids, exclude_ids:, &block).build
1313
end
1414

1515
class_attribute :traversal_strategy, instance_writer: false
@@ -48,8 +48,8 @@ def config
4848
# Subclasses may override this method to provide sane defaults.
4949
#
5050
# @return [ActsAsRecursiveTree::Options::QueryOptions] the new QueryOptions instance
51-
def get_query_options(&block)
52-
ActsAsRecursiveTree::Options::QueryOptions.from(&block)
51+
def get_query_options(&)
52+
ActsAsRecursiveTree::Options::QueryOptions.from(&)
5353
end
5454

5555
def base_table

lib/acts_as_recursive_tree/model.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,34 @@ module Model
99
#
1010
# subchild1.ancestors # => [child1, root]
1111
#
12-
def ancestors(&block)
13-
base_class.ancestors_of(self, &block)
12+
def ancestors(&)
13+
base_class.ancestors_of(self, &)
1414
end
1515

1616
# Returns ancestors and current node itself.
1717
#
1818
# subchild1.self_and_ancestors # => [subchild1, child1, root]
1919
#
20-
def self_and_ancestors(&block)
21-
base_class.self_and_ancestors_of(self, &block)
20+
def self_and_ancestors(&)
21+
base_class.self_and_ancestors_of(self, &)
2222
end
2323

2424
##
2525
# Returns list of descendants, starting from current node, not including current node.
2626
#
2727
# root.descendants # => [child1, child2, subchild1, subchild2, subchild3, subchild4]
2828
#
29-
def descendants(&block)
30-
base_class.descendants_of(self, &block)
29+
def descendants(&)
30+
base_class.descendants_of(self, &)
3131
end
3232

3333
##
3434
# Returns list of descendants, starting from current node, including current node.
3535
#
3636
# root.self_and_descendants # => [root, child1, child2, subchild1, subchild2, subchild3, subchild4]
3737
#
38-
def self_and_descendants(&block)
39-
base_class.self_and_descendants_of(self, &block)
38+
def self_and_descendants(&)
39+
base_class.self_and_descendants_of(self, &)
4040
end
4141

4242
##
@@ -50,7 +50,7 @@ def root
5050
#
5151
# subchild1.siblings # => [subchild2]
5252
def siblings
53-
self_and_siblings.where.not(id: id)
53+
self_and_siblings.where.not(id:)
5454
end
5555

5656
##
@@ -97,7 +97,7 @@ def leaf?
9797
# @param includes [Array|Hash] pass the same arguments that should be passed to the #includes() method.
9898
#
9999
def preload_tree(includes: nil)
100-
ActsAsRecursiveTree::Preloaders::Descendants.new(self, includes: includes).preload!
100+
ActsAsRecursiveTree::Preloaders::Descendants.new(self, includes:).preload!
101101
true
102102
end
103103

@@ -108,28 +108,28 @@ def base_class
108108
private :base_class
109109

110110
module ClassMethods
111-
def self_and_ancestors_of(ids, &block)
112-
ActsAsRecursiveTree::Builders::Ancestors.build(self, ids, &block)
111+
def self_and_ancestors_of(ids, &)
112+
ActsAsRecursiveTree::Builders::Ancestors.build(self, ids, &)
113113
end
114114

115-
def ancestors_of(ids, &block)
116-
ActsAsRecursiveTree::Builders::Ancestors.build(self, ids, exclude_ids: true, &block)
115+
def ancestors_of(ids, &)
116+
ActsAsRecursiveTree::Builders::Ancestors.build(self, ids, exclude_ids: true, &)
117117
end
118118

119119
def roots_of(ids)
120120
self_and_ancestors_of(ids).roots
121121
end
122122

123-
def self_and_descendants_of(ids, &block)
124-
ActsAsRecursiveTree::Builders::Descendants.build(self, ids, &block)
123+
def self_and_descendants_of(ids, &)
124+
ActsAsRecursiveTree::Builders::Descendants.build(self, ids, &)
125125
end
126126

127-
def descendants_of(ids, &block)
128-
ActsAsRecursiveTree::Builders::Descendants.build(self, ids, exclude_ids: true, &block)
127+
def descendants_of(ids, &)
128+
ActsAsRecursiveTree::Builders::Descendants.build(self, ids, exclude_ids: true, &)
129129
end
130130

131-
def leaves_of(ids, &block)
132-
ActsAsRecursiveTree::Builders::Leaves.build(self, ids, &block)
131+
def leaves_of(ids, &)
132+
ActsAsRecursiveTree::Builders::Leaves.build(self, ids, &)
133133
end
134134
end
135135
end

lib/acts_as_recursive_tree/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module ActsAsRecursiveTree
4-
VERSION = '3.5.0'
4+
VERSION = '4.0.0'
55
end

spec/db/database.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
ActiveRecord::Migration.verbose = false
1212

13-
ActiveRecord::Base.configurations = YAML.safe_load(File.read("#{database_folder}/database.yml"))
13+
ActiveRecord::Base.configurations = YAML.safe_load_file("#{database_folder}/database.yml")
1414

1515
if ActiveRecord.version >= Gem::Version.new('6.1.0')
1616
config = ActiveRecord::Base.configurations.configs_for env_name: database_adapter, name: 'primary'

0 commit comments

Comments
 (0)