Skip to content

Commit

Permalink
Merge pull request #1276 from activerecord-hackery/drop-rails-5.2-sup…
Browse files Browse the repository at this point in the history
…port

Drop rails 5.2 support
  • Loading branch information
deivid-rodriguez authored Mar 7, 2022
2 parents a6f91a4 + feed41c commit 0bd60d3
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 158 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,13 @@ jobs:
- v6.1.4
- v6.0.4
- 6-0-stable
- 5-2-stable
- v5.2.4
ruby:
- 3.0.2
- 2.7.4
- 2.6.7
exclude:
- rails: v7.0.0
ruby: 2.6.7
- rails: v5.2.4
ruby: 3.0.2
- rails: 5-2-stable
ruby: 3.0.2
env:
DB: sqlite3
RAILS: ${{ matrix.rails }}
Expand All @@ -52,19 +46,13 @@ jobs:
- v6.1.4
- v6.0.4
- 6-0-stable
- 5-2-stable
- v5.2.4
ruby:
- 3.0.2
- 2.7.4
- 2.6.7
exclude:
- rails: v7.0.0
ruby: 2.6.7
- rails: v5.2.4
ruby: 3.0.2
- rails: 5-2-stable
ruby: 3.0.2
env:
DB: mysql
RAILS: ${{ matrix.rails }}
Expand Down Expand Up @@ -98,19 +86,13 @@ jobs:
- v6.1.4
- v6.0.4
- 6-0-stable
- 5-2-stable
- v5.2.4
ruby:
- 3.0.2
- 2.7.4
- 2.6.7
exclude:
- rails: v7.0.0
ruby: 2.6.7
- rails: v5.2.4
ruby: 3.0.2
- rails: 5-2-stable
ruby: 3.0.2
env:
DB: postgres
RAILS: ${{ matrix.rails }}
Expand Down
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ Here's a quick guide:
2. Create a thoughtfully-named branch for your changes (`git checkout -b my-new-feature`).

3. Install the development dependencies by running `bundle install`.
To install rails other than latest (set in Gemfile): `RAILS='5-2-stable' bundle install`

$ RAILS='5-2-stable' bundle install
To install rails other than latest (set in Gemfile): `RAILS='6-0-stable' bundle install`

4. Begin by running the tests. We only take pull requests with passing tests,
and it's great to know that you have a clean slate:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ or controller layer, you're probably not looking for Ransack.

## Getting started

Ransack is supported for Rails 7.0, 6.x, 5.2 on Ruby 2.6.6 and later.
Ransack is supported for Rails 7.0, 6.x on Ruby 2.6.6 and later.

In your Gemfile, for the last officially released gem:

Expand Down
20 changes: 0 additions & 20 deletions lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb

This file was deleted.

79 changes: 0 additions & 79 deletions lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb

This file was deleted.

11 changes: 0 additions & 11 deletions lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb

This file was deleted.

21 changes: 20 additions & 1 deletion lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
require 'polyamorous/activerecord_5.2_ruby_2/join_association'
module Polyamorous
module JoinAssociationExtensions
include SwappingReflectionClass
def self.prepended(base)
base.class_eval { attr_reader :join_type }
end

def initialize(reflection, children, polymorphic_class = nil, join_type = Arel::Nodes::InnerJoin)
@join_type = join_type
if polymorphic_class && ::ActiveRecord::Base > polymorphic_class
swapping_reflection_klass(reflection, polymorphic_class) do |reflection|
super(reflection, children)
self.reflection.options[:polymorphic] = true
end
else
super(reflection, children)
end
end
end
end
1 change: 0 additions & 1 deletion lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# active_record_6.0_ruby_2/join_dependency.rb
module Polyamorous
module JoinDependencyExtensions
# Replaces ActiveRecord::Associations::JoinDependency#build
Expand Down
12 changes: 11 additions & 1 deletion lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
require 'polyamorous/activerecord_5.2_ruby_2/reflection'
module Polyamorous
module ReflectionExtensions
def join_scope(table, foreign_table, foreign_klass)
if respond_to?(:polymorphic?) && polymorphic?
super.where!(foreign_table[foreign_type].eq(klass.name))
else
super
end
end
end
end
1 change: 0 additions & 1 deletion lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# active_record_6.1_ruby_2/join_dependency.rb
module Polyamorous
module JoinDependencyExtensions
# Replaces ActiveRecord::Associations::JoinDependency#build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def value_from(predicate)
if predicate.respond_to?(:value)
predicate.value # Rails 6.1
elsif predicate.respond_to?(:val)
predicate.val # Rails 5.2, 6.0
predicate.val # Rails 6.0
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/ransack/helpers/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def html_options(args)
private

def parameters_hash(params)
if ::ActiveRecord::VERSION::MAJOR >= 5 && params.respond_to?(:to_unsafe_h)
if params.respond_to?(:to_unsafe_h)
params.to_unsafe_h
else
params
Expand Down
4 changes: 2 additions & 2 deletions ransack.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.6'
s.license = 'MIT'

s.add_dependency 'activerecord', '>= 5.2.4'
s.add_dependency 'activesupport', '>= 5.2.4'
s.add_dependency 'activerecord', '>= 6.0.4'
s.add_dependency 'activesupport', '>= 6.0.4'
s.add_dependency 'i18n'

s.files = `git ls-files`.split("\n")
Expand Down
16 changes: 0 additions & 16 deletions spec/polyamorous/join_dependency_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,5 @@ module Polyamorous
specify { expect(subject.send(:join_root).drop(1)[1].table_name)
.to eq 'comments' }
end

context '#left_outer_join in Rails 5 overrides join type specified',
if: ActiveRecord::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MAJOR < 6 && ActiveRecord::VERSION::MINOR < 2 do

let(:join_type_class) do
new_join_dependency(
Person,
new_join(:articles)
).join_constraints(
[],
Arel::Nodes::OuterJoin
).first.joins.map(&:class)
end

specify { expect(join_type_class).to eq [Arel::Nodes::OuterJoin] }
end
end
end
3 changes: 1 addition & 2 deletions spec/ransack/helpers/form_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,7 @@ module Helpers
it { should match /exist\=existing/ }
end

context 'using a real ActionController::Parameter object',
if: ::ActiveRecord::VERSION::MAJOR > 3 do
context 'using a real ActionController::Parameter object' do

describe 'with symbol q:, #sort_link should include search params' do
subject { @controller.view_context.sort_link(Person.ransack, :name) }
Expand Down

0 comments on commit 0bd60d3

Please sign in to comment.