From 408aa74dc65aee9c90141b3d3314a2d0aae0cd37 Mon Sep 17 00:00:00 2001 From: Jared Beck Date: Wed, 20 Sep 2017 05:09:41 -0400 Subject: [PATCH] Drop support for rails 4.0 and 4.1 EoL for both was 2016-06-30 http://weblog.rubyonrails.org/2016/6/30/Rails-5-0-final/ PT continued to support them for 15 months after EoL. --- .travis.yml | 1 - Appraisals | 10 +++------- CHANGELOG.md | 4 +++- gemfiles/ar_4.0.gemfile | 7 ------- gemfiles/ar_master.gemfile | 9 --------- lib/paper_trail/record_trail.rb | 9 ++------- lib/paper_trail/version_concern.rb | 5 +---- paper_trail.gemspec | 4 ++-- spec/dummy_app/config/boot.rb | 14 +++----------- 9 files changed, 14 insertions(+), 49 deletions(-) delete mode 100644 gemfiles/ar_4.0.gemfile delete mode 100644 gemfiles/ar_master.gemfile diff --git a/.travis.yml b/.travis.yml index bc575721..cd691a66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,6 @@ before_script: - sh -c "if [ \"$DB\" = 'postgres' ]; then psql -c 'create database paper_trail_foo;' -U postgres; fi" gemfile: - - gemfiles/ar_4.0.gemfile - gemfiles/ar_4.2.gemfile - gemfiles/ar_5.0.gemfile - gemfiles/ar_5.1.gemfile diff --git a/Appraisals b/Appraisals index a698d399..73c82cbe 100644 --- a/Appraisals +++ b/Appraisals @@ -7,20 +7,16 @@ # > the version from the appraisal takes precedence. # > https://github.com/thoughtbot/appraisal -appraise "ar-4.0" do - gem "activerecord", "~> 4.0" -end - appraise "ar-4.2" do - gem "activerecord", "~> 4.2" + gem "activerecord", "~> 4.2.9" end appraise "ar-5.0" do - gem "activerecord", "~> 5.0.3" + gem "activerecord", "~> 5.0.6" gem "rails-controller-testing" end appraise "ar-5.1" do - gem "rails", "5.1.1" + gem "activerecord", "~> 5.1.4" gem "rails-controller-testing" end diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dd8b98b..7a95eed5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/). ### Breaking Changes -- Drop support for ruby 2.1, whose EoL was 2017-04-01 +- Drop support for rails 4.0 and 4.1, whose EoL was + [2016-06-30](http://weblog.rubyonrails.org/2016/6/30/Rails-5-0-final/) +- Drop support for ruby 2.1, whose EoL was [2017-04-01](http://bit.ly/2ppWDYa) - [#803](https://github.com/airblade/paper_trail/issues/803) - where_object_changes no longer supports reading json from a text column diff --git a/gemfiles/ar_4.0.gemfile b/gemfiles/ar_4.0.gemfile deleted file mode 100644 index 13849560..00000000 --- a/gemfiles/ar_4.0.gemfile +++ /dev/null @@ -1,7 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "activerecord", "~> 4.0" - -gemspec path: "../" diff --git a/gemfiles/ar_master.gemfile b/gemfiles/ar_master.gemfile deleted file mode 100644 index 27f4bde6..00000000 --- a/gemfiles/ar_master.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails", github: "rails/rails" -gem "rspec-rails", "~> 3.5.1" -gem "rails-controller-testing" - -gemspec path: "../" diff --git a/lib/paper_trail/record_trail.rb b/lib/paper_trail/record_trail.rb index d37ecb35..85f5f45d 100644 --- a/lib/paper_trail/record_trail.rb +++ b/lib/paper_trail/record_trail.rb @@ -1,10 +1,7 @@ module PaperTrail # Represents the "paper trail" for a single record. class RecordTrail - # The respond_to? check here is specific to ActiveRecord 4.0 and can be - # removed when support for ActiveRecord < 4.2 is dropped. - RAILS_GTE_5_1 = ::ActiveRecord.respond_to?(:gem_version) && - ::ActiveRecord.gem_version >= ::Gem::Version.new("5.1.0.beta1") + RAILS_GTE_5_1 = ::ActiveRecord.gem_version >= ::Gem::Version.new("5.1.0.beta1") def initialize(record) @record = record @@ -477,9 +474,7 @@ module PaperTrail if @in_after_callback && RAILS_GTE_5_1 @record.attribute_before_last_save(attr_name.to_s) else - # TODO: after dropping support for rails 4.0, remove send, because - # attribute_was is no longer private. - @record.send(:attribute_was, attr_name.to_s) + @record.attribute_was(attr_name.to_s) end end diff --git a/lib/paper_trail/version_concern.rb b/lib/paper_trail/version_concern.rb index 3fe66917..8af914e6 100644 --- a/lib/paper_trail/version_concern.rb +++ b/lib/paper_trail/version_concern.rb @@ -12,10 +12,7 @@ module PaperTrail extend ::ActiveSupport::Concern included do - # The respond_to? check here is specific to ActiveRecord 4.0 and can be - # removed when support for ActiveRecord < 4.2 is dropped. - if ::ActiveRecord.respond_to?(:gem_version) && - ::ActiveRecord.gem_version >= Gem::Version.new("5.0") + if ::ActiveRecord.gem_version >= Gem::Version.new("5.0") belongs_to :item, polymorphic: true, optional: true else belongs_to :item, polymorphic: true diff --git a/paper_trail.gemspec b/paper_trail.gemspec index bc518cd6..13174fee 100644 --- a/paper_trail.gemspec +++ b/paper_trail.gemspec @@ -26,7 +26,7 @@ has been destroyed. s.required_ruby_version = ">= 2.2.0" # Rails does not follow semver, makes breaking changes in minor versions. - s.add_dependency "activerecord", [">= 4.0", "< 5.2"] + s.add_dependency "activerecord", [">= 4.2", "< 5.2"] s.add_dependency "request_store", "~> 1.1" s.add_development_dependency "appraisal", "~> 2.1" @@ -34,7 +34,7 @@ has been destroyed. s.add_development_dependency "ffaker", "~> 2.5" # Why `railties`? Possibly used by `spec/dummy_app` boot up? - s.add_development_dependency "railties", [">= 4.0", "< 5.2"] + s.add_development_dependency "railties", [">= 4.2", "< 5.2"] s.add_development_dependency "rack-test", "~> 0.6.3" s.add_development_dependency "rspec-rails", "~> 3.5" diff --git a/spec/dummy_app/config/boot.rb b/spec/dummy_app/config/boot.rb index 566c7895..d3a6413d 100644 --- a/spec/dummy_app/config/boot.rb +++ b/spec/dummy_app/config/boot.rb @@ -1,16 +1,8 @@ require "rubygems" -# We normally use the root project Gemfile (and gemspec), but when we run rake -# locally (not on travis) in this dummy app, we set the BUNDLE_GEMFILE env. -# variable. The project Gemfile/gemspec allows AR 4.0, which is a problem -# because this dummy app uses `enum` in some of its models, and `enum` was -# introduced in AR 4.1. So, when we run rake here, we use: -# -# BUNDLE_GEMFILE=../../gemfiles/ar_4.2.gemfile bundle exec rake -# -# Once we drop support for AR 4.0 and 4.1 this will be less of a problem, but -# we should keep the ability to specify BUNDLE_GEMFILE because the same -# situation could come up in the future. +# When you run rake locally (not on travis) in this dummy app, set the +# BUNDLE_GEMFILE env. variable to ensure that the correct version of AR is used +# for e.g. migrations. See examples in CONTRIBUTING.md. unless ENV.key?("BUNDLE_GEMFILE") gemfile = File.expand_path("../../../../Gemfile", __FILE__) if File.exist?(gemfile)