Skip to content

Commit

Permalink
Fix rails 7.1 on ruby 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasfed committed Oct 30, 2023
1 parent ac19977 commit 4ddd602
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
- rails_7
- rails_71
include:
- ruby-version: 2.7.8
appraisal: rails_71
- ruby-version: 2.5.9
appraisal: rails_none
env:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
== 0.7.1
- fix ruby 2.7 on rails 7.1

== 0.7.0
- support for Rails 7.1
- make install critical section smaller to prevent installation deprecations preventing installation
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
deprecation_collector (0.7.0)
deprecation_collector (0.7.1)
redis (>= 3.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_6.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
deprecation_collector (0.7.0)
deprecation_collector (0.7.1)
redis (>= 3.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_7.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
deprecation_collector (0.7.0)
deprecation_collector (0.7.1)
redis (>= 3.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_71.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
deprecation_collector (0.7.0)
deprecation_collector (0.7.1)
redis (>= 3.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_none.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
deprecation_collector (0.7.0)
deprecation_collector (0.7.1)
redis (>= 3.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion lib/deprecation_collector/collectors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def tap_warning_class
def tap_activesupport
# TODO: a more polite hook
# not polite to turn off all other possible behaviors, but otherwise may get duplicate calls
if Rails.respond_to?(:gem_version) && Rails.gem_version >= "7.1"
if Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new("7.1")
Rails.application.deprecators.behavior = ACTIVE_SUPPORT_BEHAVIORS[:rails71] if Rails.application&.deprecators
# Rails.application.deprecators.behavior only captures new-style deprecations, but we need all:
if ActiveSupport::Deprecation.respond_to?(:_instance)
Expand Down
2 changes: 1 addition & 1 deletion lib/deprecation_collector/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class DeprecationCollector
VERSION = "0.7.0"
VERSION = "0.7.1"
end
2 changes: 1 addition & 1 deletion lib/deprecation_collector/web/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def trigger_rails_deprecation
return unless defined?(ActiveSupport::Deprecation)

deprecator = ActiveSupport::Deprecation
deprecator = ActiveSupport::Deprecation.new("0.0", "deprecation_collector") if Rails.gem_version >= "7.1"
deprecator = ActiveSupport::Deprecation.new("0.0", "deprecation_collector") if Rails.gem_version >= Gem::Version.new("7.1")

-> { deprecator.warn("Test deprecation") } []
end
Expand Down
5 changes: 4 additions & 1 deletion spec/deprecation_collector/web_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,15 @@

it "trigger" do
if defined?(ActiveSupport)
if Rails.gem_version >= "7.1"
if Rails.gem_version >= Gem::Version.new("7.1")
expect_any_instance_of(ActiveSupport::Deprecation).to receive(:warn).with(a_string_matching(/Test/))
else
expect(ActiveSupport::Deprecation).to receive(:warn).with(a_string_matching(/Test/))
end
end
if RUBY_VERSION.start_with?("2.7")
expect_any_instance_of(DeprecationCollector::Web::Router::ActionContext).to receive(:trigger_kwargs_error_warning)
end
expect($stderr).to receive(:puts).with(a_string_matching(/Test/))
post "/trigger"
expect(last_response.status).to eq(302)
Expand Down
6 changes: 3 additions & 3 deletions spec/deprecation_collector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

describe "activesupport" do
let(:deprecator) do
if Rails.gem_version >= "7.1"
if Rails.gem_version >= Gem::Version.new("7.1")
ActiveSupport::Deprecation._instance
else
ActiveSupport::Deprecation
Expand Down Expand Up @@ -147,7 +147,7 @@
end

it "also collects" do
skip unless Rails.gem_version >= "7.1"
skip unless Rails.gem_version >= Gem::Version.new("7.1")

expect { trigger_deprecation[] }.to change(collector, :unsent_data?).from(false).to(true)

Expand All @@ -169,7 +169,7 @@
end

it "also collects" do
skip unless Rails.gem_version >= "7.1"
skip unless Rails.gem_version >= Gem::Version.new("7.1")
expect { trigger_deprecation[] }.to change(collector, :unsent_data?).from(false).to(true)

collector.write_to_redis(force: true)
Expand Down

0 comments on commit 4ddd602

Please sign in to comment.