diff --git a/.travis.yml b/.travis.yml index 645521b98..bffcb1a99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,12 @@ matrix: exclude: - rvm: 2.4.2 gemfile: gemfiles/activerecord_6.0.0.gemfile + - rvm: 2.2.6 + gemfile: gemfiles/activerecord_6.1.0.gemfile + - rvm: 2.3.5 + gemfile: gemfiles/activerecord_6.1.0.gemfile + - rvm: 2.4.2 + gemfile: gemfiles/activerecord_6.1.0.gemfile - rvm: 2.2.6 gemfile: gemfiles/activerecord_master.gemfile - rvm: 2.3.5 diff --git a/CHANGELOG.md b/CHANGELOG.md index cd0cef457..d9a426283 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.2.1 + +* [#674](https://github.com/CanCanCommunity/cancancan/pull/674): Fix accidental dependency on ActiveRecord in 3.2.0. ([@ghiculescu][]) + ## 3.2.0 * [#649](https://github.com/CanCanCommunity/cancancan/pull/649): Add support for Single Table Inheritance. ([@Liberatys][]) diff --git a/lib/cancan/config.rb b/lib/cancan/config.rb index 74f7253a0..19243395e 100644 --- a/lib/cancan/config.rb +++ b/lib/cancan/config.rb @@ -3,7 +3,7 @@ module CanCan def self.valid_accessible_by_strategies strategies = [:left_join] - strategies << :subquery unless CanCan::ModelAdapters::ActiveRecordAdapter.version_lower?('5.0.0') + strategies << :subquery unless does_not_support_subquery_strategy? strategies end @@ -25,7 +25,7 @@ def self.accessible_by_strategy end def self.default_accessible_by_strategy - if CanCan::ModelAdapters::ActiveRecordAdapter.version_lower?('5.0.0') + if does_not_support_subquery_strategy? # see https://github.com/CanCanCommunity/cancancan/pull/655 for where this was added # the `subquery` strategy (from https://github.com/CanCanCommunity/cancancan/pull/619 # only works in Rails 5 and higher @@ -40,10 +40,15 @@ def self.accessible_by_strategy=(value) raise ArgumentError, "accessible_by_strategy must be one of #{valid_accessible_by_strategies.join(', ')}" end - if value == :subquery && CanCan::ModelAdapters::ActiveRecordAdapter.version_lower?('5.0.0') + if value == :subquery && does_not_support_subquery_strategy? raise ArgumentError, 'accessible_by_strategy = :subquery requires ActiveRecord 5 or newer' end @accessible_by_strategy = value end + + def self.does_not_support_subquery_strategy? + !defined?(CanCan::ModelAdapters::ActiveRecordAdapter) || + CanCan::ModelAdapters::ActiveRecordAdapter.version_lower?('5.0.0') + end end diff --git a/lib/cancan/version.rb b/lib/cancan/version.rb index 68d5417a9..cb0fe0e92 100644 --- a/lib/cancan/version.rb +++ b/lib/cancan/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module CanCan - VERSION = '3.2.0'.freeze + VERSION = '3.2.1'.freeze end