Skip to content

Commit

Permalink
[Fix #903] Fix deprecation warning in LogSubscriber when updating to …
Browse files Browse the repository at this point in the history
…Rails 7.1
  • Loading branch information
alejandroperea committed Dec 6, 2023
1 parent 22ead9a commit 8bbd11b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
fail-fast: false
matrix:
ruby: [ '3.0', '3.1', '3.2' ]
gemfile: [ rails.6.1.activerecord, rails.7.0.activerecord ]
gemfile: [ rails.6.1.activerecord, rails.7.0.activerecord, rails.7.1.activerecord ]
name: ${{ matrix.ruby }}-${{ matrix.gemfile }}

env:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### New Features

* [#888](/~https://github.com/toptal/chewy/pull/907): Fix deprecation warning in LogSubscriber for Rails 7.1 ([@alejandroperea](/~https://github.com/alejandroperea))

### Changes

### Bugs Fixed
Expand Down
13 changes: 13 additions & 0 deletions gemfiles/rails.7.1.activerecord.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source 'https://rubygems.org'

gem 'activejob', '~> 7.1.0'
gem 'activerecord', '~> 7.1.0'
gem 'activesupport', '~> 7.1.0'
gem 'kaminari-core', '~> 1.1.0', require: false
gem 'parallel', require: false
gem 'rspec_junit_formatter', '~> 0.4.1'
gem 'sidekiq', require: false

gem 'rexml' if RUBY_VERSION >= '3.0.0'

gemspec path: '../'
2 changes: 1 addition & 1 deletion lib/chewy.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'active_support/version'
require 'active_support/concern'
require 'active_support/deprecation'
require 'active_support/deprecation' if ActiveSupport.version < '7.1'
require 'active_support/json'
require 'active_support/log_subscriber'

Expand Down
6 changes: 5 additions & 1 deletion lib/chewy/log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def render_action(action, event)

subject = payload[:type].presence || payload[:index]
action = "#{subject} #{action} (#{event.duration.round(1)}ms)"
action = color(action, GREEN, true)
action = if ActiveSupport.version >= '7.1'
color(action, GREEN, bold: true)
else
color(action, GREEN, true)
end

debug(" #{action} #{description}")
end
Expand Down

0 comments on commit 8bbd11b

Please sign in to comment.