From c6630ea567d47e174532eac6ab84fe2f12fdb2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 20 Nov 2020 13:49:33 +0100 Subject: [PATCH] Drop support for activerecord older than 5.2.4 --- .travis.yml | 6 +++--- CHANGELOG.md | 3 +++ .../activerecord_5.2_ruby_2/reflection.rb | 20 +++++-------------- ransack.gemspec | 4 ++-- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index d4828f2..82f937e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,9 +19,9 @@ env: - RAILS=5-2-stable DB=mysql - RAILS=5-2-stable DB=postgres - - RAILS=v5.2.3 DB=sqlite3 - - RAILS=v5.2.3 DB=mysql - - RAILS=v5.2.3 DB=postgres + - RAILS=v5.2.4 DB=sqlite3 + - RAILS=v5.2.4 DB=mysql + - RAILS=v5.2.4 DB=postgres before_script: - if [ "$DB" = "mysql" ]; diff --git a/CHANGELOG.md b/CHANGELOG.md index 74a3f87..5c5df2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ * Fix for ActiveRecord 5.2.4 (note security fix in 5.2.4.2 for ActiveView's escape_javascript CVE-2020-5267 for all earlier versions) +* Drop support for ActiveRecord older than 5.2.4. + PR [1166](https://github.com/activerecord-hackery/ransack/pull/1166) + ## 2.3.2 - 2020-01-11 * Breakfix to bump Polyamorous diff --git a/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb b/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb index 9e0bfb6..bea4b97 100644 --- a/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb +++ b/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb @@ -1,20 +1,10 @@ module Polyamorous module ReflectionExtensions - if ActiveRecord.version > ::Gem::Version.new('5.2.3') - 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 - else - def build_join_constraint(table, foreign_table) - if polymorphic? - super.and(foreign_table[foreign_type].eq(klass.name)) - else - super - end + 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 diff --git a/ransack.gemspec b/ransack.gemspec index dedaf8c..8dfe875 100644 --- a/ransack.gemspec +++ b/ransack.gemspec @@ -14,8 +14,8 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.3' s.license = 'MIT' - s.add_dependency 'activerecord', '>= 5.2.1' - s.add_dependency 'activesupport', '>= 5.2.1' + s.add_dependency 'activerecord', '>= 5.2.4' + s.add_dependency 'activesupport', '>= 5.2.4' s.add_dependency 'i18n' s.files = `git ls-files`.split("\n")