Skip to content

Commit

Permalink
Add support for Rails 7.1
Browse files Browse the repository at this point in the history
Require ransack >= 4.1 for Rails 7.1 support.

Two major changes in Rails 7.1 are:
- [NullRelation was removed][null_relation], but it seems the behaviour
  changed in Rails 7.0 such that the special handling was no longer
  required anyway
- [ActiveSupport::Deprecation singleton was deprecated][deprecation]

[null_relation]: rails/rails#47800
[deprecation]: rails/rails#47354
  • Loading branch information
owst authored and rzane committed Nov 4, 2023
1 parent c5ec16c commit 3535fdb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion baby_squeel.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|

spec.files = Dir.glob('{lib/**/*,*.{md,txt,gemspec}}')

spec.add_dependency 'activerecord', '>= 6.1', '< 7.1'
spec.add_dependency 'activerecord', '>= 6.1.6', '< 7.2'
spec.add_dependency 'ransack', '~> 4.1'

spec.add_development_dependency 'bundler', '~> 2'
Expand Down
2 changes: 1 addition & 1 deletion lib/baby_squeel/nodes/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _arel
# Conveniently, this approach automatically adds a 1=0.
# I have literally no idea why, but I'll take it.
def sanitize_relation(rel)
if rel.kind_of? ::ActiveRecord::NullRelation
if ::ActiveRecord::VERSION::MAJOR < 7 && rel.kind_of?(::ActiveRecord::NullRelation)
other = rel.spawn
other.extending_values -= [::ActiveRecord::NullRelation]
sanitize_relation rel.unscoped.merge(other)
Expand Down
7 changes: 6 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
require 'support/factories'
require 'support/query_tracker'

ActiveSupport::Deprecation.behavior = :raise
if ActiveSupport.respond_to?(:deprecator)
ActiveSupport.deprecator.behavior = :raise
ActiveRecord.deprecator.behavior = :raise
else
ActiveSupport::Deprecation.behavior = :raise
end

RSpec.configure do |config|
config.include Factories
Expand Down

0 comments on commit 3535fdb

Please sign in to comment.