Skip to content

Commit 14b6cfd

Browse files
authored
Drop rails 6.1/7.0 and ruby 3.0/3.1 support (#1514)
* Drop rails 6.1/7.0 and ruby 3.0/3.1 support * upgrade rubocop-rspec + rspec-rails * disable RSpec/IndexedLet * autofix RSpec/IndexedLet * auto-fix Style/ArrayIntersect * autofix RSpec/ReceiveMessages * autofix RSpec/MetadataStyle * revert changes from bad rebase * revert .rubocop_todo.yml changes * empty line
1 parent 3cc736e commit 14b6cfd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+169
-192
lines changed

Diff for: .github/CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ For most development, testing with sqlite only is easiest and sufficient. CI
5454
will run the rest.
5555

5656
```
57-
DB=sqlite bundle exec appraisal rails-6.1 rake
58-
DB=sqlite bundle exec appraisal rails-7.0 rake
59-
DB=mysql bundle exec appraisal rails-7.0 rake
57+
DB=sqlite bundle exec appraisal rails-7.1 rake
58+
DB=sqlite bundle exec appraisal rails-8.0 rake
59+
DB=mysql bundle exec appraisal rails-7.1 rake
6060
createuser --superuser postgres
61-
DB=postgres bundle exec appraisal rails-7.0 rake
61+
DB=postgres bundle exec appraisal rails-7.1 rake
6262
```
6363

6464
## The dummy_app

Diff for: .github/workflows/test.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
uses: ruby/setup-ruby@v1
1818
with:
1919
# See "Lowest supported ruby version" in CONTRIBUTING.md
20-
ruby-version: '3.0'
20+
ruby-version: '3.2'
2121
- name: Bundle
2222
run: |
2323
gem install bundler
@@ -59,18 +59,11 @@ jobs:
5959
# have set this up with each database as a separate job, but then we'd be
6060
# duplicating the matrix configuration three times.
6161
matrix:
62-
gemfile: [ 'rails_6.1', 'rails_7.0', 'rails_7.1', 'rails_7.2', 'rails_8.0' ]
62+
gemfile: [ 'rails_7.1', 'rails_7.2', 'rails_8.0' ]
6363

6464
# To keep matrix size down, only test highest and lowest rubies.
6565
# See "Lowest supported ruby version" in CONTRIBUTING.md
66-
ruby: [ '3.0', '3.3' ]
67-
exclude:
68-
# Rails 8 requires ruby 3.2+.
69-
- gemfile: 'rails_8.0'
70-
ruby: '3.0'
71-
# Rails 7.2 requires ruby 3.1+.
72-
- gemfile: 'rails_7.2'
73-
ruby: '3.0'
66+
ruby: [ '3.2', '3.4' ]
7467
steps:
7568
- name: Checkout source
7669
uses: actions/checkout@v4

Diff for: .rubocop.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
require:
2-
- rubocop-rspec
3-
41
plugins:
52
- rubocop-packaging
63
- rubocop-performance
74
- rubocop-rails
85
- rubocop-rake
6+
- rubocop-rspec
97

108
inherit_from: .rubocop_todo.yml
119

@@ -25,7 +23,7 @@ AllCops:
2523
NewCops: enable
2624

2725
# See "Lowest supported ruby version" in CONTRIBUTING.md
28-
TargetRubyVersion: 3.0
26+
TargetRubyVersion: 3.2
2927

3028
Gemspec/DevelopmentDependencies:
3129
Enabled: false
@@ -147,6 +145,9 @@ RSpec/DescribeClass:
147145
RSpec/ExampleLength:
148146
Enabled: false
149147

148+
RSpec/IndexedLet:
149+
Enabled: false
150+
150151
# In an ideal world, each example has a single expectation. In the real world,
151152
# sometimes setup is a pain and you don't want to duplicate setup in multiple
152153
# examples, or make the specs more confusing with many nested `context`s, and

Diff for: Appraisals

-10
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@
99
# > the version from the appraisal takes precedence.
1010
# > https://github.com/thoughtbot/appraisal
1111

12-
appraise "rails-6.1" do
13-
gem "rails", "~> 6.1.0"
14-
gem "rails-controller-testing", "~> 1.0.5"
15-
end
16-
17-
appraise "rails-7.0" do
18-
gem "rails", "~> 7.0.3.1"
19-
gem "rails-controller-testing", "~> 1.0.5"
20-
end
21-
2212
appraise "rails-7.1" do
2313
gem "rails", "~> 7.1.0"
2414
gem "rails-controller-testing", "~> 1.0.5"

Diff for: CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).
1717

1818
- None
1919

20+
### Dependencies
21+
22+
- Drop support for Rails 6.1, which [reached EoL on 2024-10-01][2]
23+
- Drop support for Rails 7.0, which [reached EoL on 2025-04-01][2]
24+
- Drop support for Ruby 3.0, which [reached EoL on 2024-04-23][3]
25+
- Drop support for Ruby 3.1, which [reached EoL on 2024-03-31][3]
26+
2027
## 16.0.0 (2024-11-08)
2128

2229
### Breaking Changes

Diff for: lib/paper_trail.rb

-4
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ def version
115115
VERSION::STRING
116116
end
117117

118-
def active_record_gte_7_0?
119-
@active_record_gte_7_0 ||= ::ActiveRecord.gem_version >= ::Gem::Version.new("7.0.0")
120-
end
121-
122118
def deprecator
123119
@deprecator ||= ActiveSupport::Deprecation.new("16.0", "PaperTrail")
124120
end

Diff for: lib/paper_trail/attribute_serializers/cast_attribute_serializer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def deserialize(attr, val)
3232
if defined_enums[attr] && val.is_a?(::String)
3333
# Because PT 4 used to save the string version of enums to `object_changes`
3434
val
35-
elsif PaperTrail.active_record_gte_7_0? && val.is_a?(ActiveRecord::Type::Time::Value)
35+
elsif val.is_a?(ActiveRecord::Type::Time::Value)
3636
# Because Rails 7 time attribute throws a delegation error when you deserialize
3737
# it with the factory.
3838
# See ActiveRecord::Type::Time::Value crashes when loaded from YAML on rails 7.0

Diff for: lib/paper_trail/attribute_serializers/object_attribute.rb

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ def initialize(model_class)
1010
@model_class = model_class
1111

1212
# ActiveRecord since 7.0 has a built-in encryption mechanism
13-
@encrypted_attributes =
14-
if PaperTrail.active_record_gte_7_0?
15-
@model_class.encrypted_attributes&.map(&:to_s)
16-
end
13+
@encrypted_attributes = @model_class.encrypted_attributes&.map(&:to_s)
1714
end
1815

1916
def serialize(attributes)

Diff for: lib/paper_trail/attribute_serializers/object_changes_attribute.rb

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ def initialize(item_class)
1010
@item_class = item_class
1111

1212
# ActiveRecord since 7.0 has a built-in encryption mechanism
13-
@encrypted_attributes =
14-
if PaperTrail.active_record_gte_7_0?
15-
@item_class.encrypted_attributes&.map(&:to_s)
16-
end
13+
@encrypted_attributes = @item_class.encrypted_attributes&.map(&:to_s)
1714
end
1815

1916
def serialize(changes)

Diff for: lib/paper_trail/compatibility.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module PaperTrail
1717
# newer rails versions. Most PT users should avoid incompatible rails
1818
# versions.
1919
module Compatibility
20-
ACTIVERECORD_GTE = ">= 6.1" # enforced in gemspec
20+
ACTIVERECORD_GTE = ">= 7.1" # enforced in gemspec
2121
ACTIVERECORD_LT = "< 8.1" # not enforced in gemspec
2222

2323
E_INCOMPATIBLE_AR = <<-EOS

Diff for: lib/paper_trail/events/base.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def evaluate_only
157157
# @api private
158158
def ignored_attr_has_changed?
159159
ignored = calculated_ignored_array + @record.paper_trail_options[:skip]
160-
ignored.any? && (changed_in_latest_version & ignored).any?
160+
ignored.any? && changed_in_latest_version.intersect?(ignored)
161161
end
162162

163163
# Rails 5.1 changed the API of `ActiveRecord::Dirty`. See

Diff for: paper_trail.gemspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ has been destroyed.
4848
# about 3 years, per https://www.ruby-lang.org/en/downloads/branches/
4949
#
5050
# See "Lowest supported ruby version" in CONTRIBUTING.md
51-
s.required_ruby_version = ">= 3.0.0"
51+
s.required_ruby_version = ">= 3.2.0"
5252

5353
# We no longer specify a maximum activerecord version.
5454
# See discussion in paper_trail/compatibility.rb
@@ -77,13 +77,13 @@ has been destroyed.
7777
s.add_development_dependency "rails", PaperTrail::Compatibility::ACTIVERECORD_GTE
7878

7979
s.add_development_dependency "rake", "~> 13.0"
80-
s.add_development_dependency "rspec-rails", "~> 6.0.3"
80+
s.add_development_dependency "rspec-rails", "~> 7.1.1"
8181
s.add_development_dependency "rubocop", "~> 1.75"
8282
s.add_development_dependency "rubocop-packaging", "~> 0.6.0"
8383
s.add_development_dependency "rubocop-performance", "~> 1.24.0"
8484
s.add_development_dependency "rubocop-rails", "~> 2.30.3"
8585
s.add_development_dependency "rubocop-rake", "~> 0.7.1"
86-
s.add_development_dependency "rubocop-rspec", "~> 2.17.0"
86+
s.add_development_dependency "rubocop-rspec", "~> 3.5.0"
8787
s.add_development_dependency "simplecov", "~> 0.21.2"
8888

8989
# ## Database Adapters

Diff for: spec/controllers/widgets_controller_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require "spec_helper"
44

5-
RSpec.describe WidgetsController, versioning: true do
5+
RSpec.describe WidgetsController, :versioning do
66
before { request.env["REMOTE_ADDR"] = "127.0.0.1" }
77

88
after { RequestStore.store[:paper_trail] = nil }

Diff for: spec/dummy_app/app/models/fruit.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ class Fruit < ApplicationRecord
66
has_paper_trail versions: { class_name: "JsonVersion" }
77
end
88

9-
if PaperTrail.active_record_gte_7_0?
10-
encrypts :supplier
11-
end
9+
encrypts :supplier
1210
end

Diff for: spec/dummy_app/app/models/vegetable.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ class Vegetable < ApplicationRecord
66
class_name: ENV["DB"] == "postgres" ? "JsonbVersion" : "PaperTrail::Version"
77
}, on: %i[create update]
88

9-
if PaperTrail.active_record_gte_7_0?
10-
encrypts :supplier
11-
end
9+
encrypts :supplier
1210
end

Diff for: spec/models/animal_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require "spec_helper"
44

5-
RSpec.describe Animal, versioning: true do
5+
RSpec.describe Animal, :versioning do
66
it "baseline test setup" do
77
expect(described_class.new).to be_versioned
88
expect(described_class.inheritance_column).to eq("species")

Diff for: spec/models/article_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require "spec_helper"
44

5-
RSpec.describe Article, versioning: true do
5+
RSpec.describe Article, :versioning do
66
describe ".create" do
77
it "also creates a version record" do
88
expect { described_class.create }.to(

Diff for: spec/models/book_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require "spec_helper"
44

5-
RSpec.describe Book, versioning: true do
5+
RSpec.describe Book, :versioning do
66
context "with :has_many :through" do
77
it "store version on source <<" do
88
book = described_class.create(title: "War and Peace")
@@ -23,7 +23,7 @@
2323
expect((PaperTrail::Version.count - count)).to(eq(2))
2424
expect(
2525
[PaperTrail::Version.order(:id).to_a[-2].item, PaperTrail::Version.last.item]
26-
).to match_array([Person.last, Authorship.last])
26+
).to contain_exactly(Person.last, Authorship.last)
2727
end
2828

2929
it "store version on join destroy" do

Diff for: spec/models/boolit_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "spec_helper"
44
require "support/custom_json_serializer"
55

6-
RSpec.describe Boolit, versioning: true do
6+
RSpec.describe Boolit, :versioning do
77
let(:boolit) { described_class.create! }
88

99
before { boolit.update!(name: FFaker::Name.name) }

Diff for: spec/models/callback_modifier_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require "spec_helper"
44

5-
RSpec.describe CallbackModifier, versioning: true do
5+
RSpec.describe CallbackModifier, :versioning do
66
describe "paper_trail_on_destroy" do
77
it "adds :destroy to paper_trail_options[:on]" do
88
modifier = NoArgDestroyModifier.create!(some_content: FFaker::Lorem.sentence)

Diff for: spec/models/car_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
RSpec.describe Car do
66
it { is_expected.to be_versioned }
77

8-
describe "changeset", versioning: true do
8+
describe "changeset", :versioning do
99
it "has the expected keys (see issue 738)" do
1010
car = described_class.create!(name: "Alice")
1111
car.update(name: "Bob")
1212
assert_includes car.versions.last.changeset.keys, "name"
1313
end
1414
end
1515

16-
describe "attributes and accessors", versioning: true do
16+
describe "attributes and accessors", :versioning do
1717
it "reifies attributes that are not AR attributes" do
1818
car = described_class.create name: "Pinto", color: "green"
1919
car.update color: "yellow"

Diff for: spec/models/cat_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require "spec_helper"
44

5-
RSpec.describe Cat, versioning: true do
5+
RSpec.describe Cat, :versioning do
66
describe "#descends_from_active_record?" do
77
it "returns false, meaning that Cat is an STI subclass" do
88
expect(described_class.descends_from_active_record?).to eq(false)

Diff for: spec/models/custom_primary_key_record_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
it { is_expected.to be_versioned }
77

88
describe "#versions" do
9-
it "returns instances of CustomPrimaryKeyRecordVersion", versioning: true do
9+
it "returns instances of CustomPrimaryKeyRecordVersion", :versioning do
1010
custom_primary_key_record = described_class.create!
1111
custom_primary_key_record.update!(name: "bob")
1212
version = custom_primary_key_record.versions.last

Diff for: spec/models/document_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require "spec_helper"
44

5-
RSpec.describe Document, versioning: true do
5+
RSpec.describe Document, :versioning do
66
describe "have_a_version_with matcher" do
77
it "works with custom versions association" do
88
document = described_class.create!(name: "Foo")

Diff for: spec/models/family/celebrity_family_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "spec_helper"
44

55
module Family
6-
RSpec.describe CelebrityFamily, versioning: true do
6+
RSpec.describe CelebrityFamily, :versioning do
77
describe "#joins" do
88
it "works on an STI model" do
99
described_class.create!

Diff for: spec/models/foo_widget_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "spec_helper"
44
require "support/performance_helpers"
55

6-
RSpec.describe(FooWidget, versioning: true) do
6+
RSpec.describe(FooWidget, :versioning) do
77
context "with a subclass" do
88
let(:foo) { described_class.create }
99

Diff for: spec/models/fruit_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "spec_helper"
44

55
if ENV["DB"] == "postgres" && JsonVersion.table_exists?
6-
RSpec.describe Fruit, versioning: true do
6+
RSpec.describe Fruit, :versioning do
77
describe "have_a_version_with_changes matcher" do
88
it "works with Fruit because Fruit uses JsonVersion" do
99
# As of PT 9.0.0, with_version_changes only supports json(b) columns,
@@ -17,7 +17,7 @@
1717
end
1818
end
1919

20-
describe "queries of versions", versioning: true do
20+
describe "queries of versions", :versioning do
2121
let!(:fruit) { described_class.create(name: "Apple", mass: 1, color: "green") }
2222

2323
before do

Diff for: spec/models/gadget_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
it { is_expected.to be_versioned }
99

10-
describe "updates", versioning: true do
10+
describe "updates", :versioning do
1111
it "generates a version for updates" do
1212
expect { gadget.update_attribute(:name, "Hammer") }.to(change { gadget.versions.size }.by(1))
1313
end

Diff for: spec/models/gizmo_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "spec_helper"
44
require "support/performance_helpers"
55

6-
RSpec.describe Gizmo, versioning: true do
6+
RSpec.describe Gizmo, :versioning do
77
context "with a persisted record" do
88
it "does not use the gizmo `updated_at` as the version's `created_at`" do
99
gizmo = described_class.create(name: "Fred", created_at: 1.day.ago)

Diff for: spec/models/joined_version_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require "spec_helper"
44

5-
RSpec.describe JoinedVersion, versioning: true do
5+
RSpec.describe JoinedVersion, :versioning do
66
let(:widget) { Widget.create!(name: FFaker::Name.name) }
77
let(:version) { described_class.first }
88

0 commit comments

Comments
 (0)