Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not override Object#to_json with mimic_json if ActiveSupport is existed #936

Merged
merged 7 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ jobs:
- no_rails
- rails_6.1
- rails_7
- rails_7.1
- rails_7.2
exclude:
- ruby: 2.7
gemfile: rails_7.2
- ruby: 3.0
gemfile: rails_7.2
- os: macos
ruby: head
- os: windows
Expand All @@ -39,6 +45,10 @@ jobs:
gemfile: rails_6.1
- os: windows
gemfile: rails_7
- os: windows
gemfile: rails_7.1
- os: windows
gemfile: rails_7.2
include:
- ruby: '2.7'
gemfile: rails_6 # End of life June 1, 2023
Expand Down
4 changes: 3 additions & 1 deletion ext/oj/mimic_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,9 @@ oj_define_mimic_json(int argc, VALUE *argv, VALUE self) {
}
oj_mimic_json_methods(json);

rb_define_method(rb_cObject, "to_json", mimic_object_to_json, -1);
if (!rb_const_defined(rb_cObject, rb_intern("ActiveSupport"))) {
rb_define_method(rb_cObject, "to_json", mimic_object_to_json, -1);
}

rb_gv_set("$VERBOSE", verbose);

Expand Down
11 changes: 11 additions & 0 deletions gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'rails', '~> 7.1.3'
gem 'sqlite3'
gem 'mutex_m'
gem 'base64'
gem 'drb'

gemspec :path => '../'
11 changes: 11 additions & 0 deletions gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'rails', '~> 7.2.0'
gem 'sqlite3'
gem 'mutex_m'
gem 'base64'
gem 'drb'

gemspec :path => '../'
5 changes: 4 additions & 1 deletion test/activesupport7/abstract_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
Thread.abort_on_exception = true

# Show backtraces for deprecated behavior for quicker cleanup.
ActiveSupport::Deprecation.debug = true
if ActiveSupport::Deprecation.respond_to?(:debug)
# Rails 7.2 does not have ActiveSupport::Deprecation.debug
ActiveSupport::Deprecation.debug = true
end

# Default to old to_time behavior but allow running tests with new behavior
ActiveSupport.to_time_preserves_timezone = ENV["PRESERVE_TIMEZONES"] == "1"
Expand Down