From e4b517c412ad14cf82b8d2ec0f76de919ac72fe4 Mon Sep 17 00:00:00 2001 From: Wasif Hossain Date: Tue, 28 Oct 2025 12:39:33 +0600 Subject: [PATCH 1/8] Pin json version to < 2.10 Context: Failure: ActiveModelSerializers::Test::SchemaTest#test_that_raises_with_a_invalid_json_body [/home/runner/work/active_model_serializers/active_model_serializers/test/active_model_serializers/test/schema_test.rb:129]: Expected /A JSON text must at least contain two octets!|unexpected token at ''/ to match "unexpected end of input at line 1 column 1". bin/rails test /home/runner/work/active_model_serializers/active_model_serializers/test/active_model_serializers/test/schema_test.rb:119 --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index a9c26e9b6..2861fae1a 100644 --- a/Gemfile +++ b/Gemfile @@ -82,6 +82,7 @@ group :test do end end gem 'codeclimate-test-reporter', require: false + gem 'json', '< 2.10', require: false gem 'm', '~> 1.5' gem 'pry', '>= 0.10' gem 'byebug', '~> 8.2' if RUBY_VERSION < '2.2' From affb7e9af6c8cd42a3669591951a1b2553e33bac Mon Sep 17 00:00:00 2001 From: Wasif Hossain Date: Tue, 28 Oct 2025 12:44:29 +0600 Subject: [PATCH 2/8] Require 'logger' Context: /home/runner/work/active_model_serializers/active_model_serializers/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.7.10/lib/active_support/logger_thread_safe_level.rb:16:in `': uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError) https://github.com/rails/rails/pull/54621 --- test/support/isolated_unit.rb | 1 + test/test_helper.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/test/support/isolated_unit.rb b/test/support/isolated_unit.rb index af80f601b..2566d2685 100644 --- a/test/support/isolated_unit.rb +++ b/test/support/isolated_unit.rb @@ -38,6 +38,7 @@ # It is also good to know what is the bare minimum to get # Rails booted up. require 'bundler/setup' unless defined?(Bundler) +require 'logger' require 'active_support' require 'active_support/core_ext/string/access' diff --git a/test/test_helper.rb b/test/test_helper.rb index 7d8ca63e3..7da8a09a6 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -4,6 +4,7 @@ ENV['RAILS_ENV'] = 'test' require 'bundler/setup' +require 'logger' require 'pry' require 'timecop' require 'rails' From cc3b3341abfc9a58e95faeffce49559f346ae5e6 Mon Sep 17 00:00:00 2001 From: Wasif Hossain Date: Tue, 28 Oct 2025 12:55:04 +0600 Subject: [PATCH 3/8] Add ostruct to Gemfile for Ruby >= 3.4 Context: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0. You can add ostruct to your Gemfile or gemspec to silence this warning. --- Gemfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index 2861fae1a..4f284cbf8 100644 --- a/Gemfile +++ b/Gemfile @@ -97,6 +97,10 @@ group :development, :test do gem 'rubocop-minitest', '~> 0.31.0', require: false gem 'rubocop-rails', '~> 2.20.0', require: false gem 'rubocop-rake', '~> 0.6.0', require: false + + if RUBY_VERSION >= '3.4.0' + gem 'ostruct', require: false + end end if version <= '5.0' gem 'loofah', '< 2.21.0' From eec4d8e5e5ee870804f2e3a8104478bf15f7a3e0 Mon Sep 17 00:00:00 2001 From: Wasif Hossain Date: Tue, 28 Oct 2025 12:56:52 +0600 Subject: [PATCH 4/8] Add mutex_m to Gemfile for Ruby >= 3.4 Context: warning: mutex_m was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0. You can add mutex_m to your Gemfile or gemspec to silence this warning. /.rvm/rubies/ruby-3.4.7/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require': cannot load such file -- mutex_m (LoadError) --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 4f284cbf8..83693517b 100644 --- a/Gemfile +++ b/Gemfile @@ -100,6 +100,7 @@ group :development, :test do if RUBY_VERSION >= '3.4.0' gem 'ostruct', require: false + gem 'mutex_m', require: false end end if version <= '5.0' From 5d9201b5b7d23b551d664786d8ffaf4cabf351b6 Mon Sep 17 00:00:00 2001 From: Wasif Hossain Date: Tue, 28 Oct 2025 13:01:25 +0600 Subject: [PATCH 5/8] Fix minitest assertion for Ruby >= 3.4 Context: Failure: ActiveModel::Serializer::ReflectionTest#test_no_href_in_vanilla_reflection [/.rvm/gems/ruby-3.4.7/gems/minitest-5.10.3/lib/minitest/assertions.rb:139]: Expected /undefined method `href'/ to match # encoding: US-ASCII "undefined method 'href' for an instance of ActiveModel::Serializer::HasOneReflection". --- test/serializers/reflection_test.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/serializers/reflection_test.rb b/test/serializers/reflection_test.rb index bb90e81c8..b8998b189 100644 --- a/test/serializers/reflection_test.rb +++ b/test/serializers/reflection_test.rb @@ -383,7 +383,10 @@ def test_no_href_in_vanilla_reflection exception = assert_raise(NoMethodError) do reflection.instance_eval(&link) end - assert_match(/undefined method `href'/, exception.message) + + expected = RUBY_VERSION >= '3.4.0' ? /undefined method 'href'/ : /undefined method `href'/ + + assert_match(expected, exception.message) end # rubocop:disable Metrics/AbcSize From 331743b1b7cda81a1abfb595eb314a29ff722f93 Mon Sep 17 00:00:00 2001 From: Wasif Hossain Date: Tue, 28 Oct 2025 13:04:04 +0600 Subject: [PATCH 6/8] Add Ruby 3.4 and Rails 8.1 to CI matrix --- .github/workflows/ci.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5a589bd8..8ee3349a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,26 +13,32 @@ jobs: matrix: include: # Recent Rubies and Rails - - ruby-version: '3.3' + - ruby-version: '3.4' + rails-version: '8.1' + - ruby-version: '3.4' rails-version: '8.0' - - ruby-version: '3.2' + - ruby-version: '3.4' + rails-version: '7.2' + - ruby-version: '3.3' rails-version: '8.0' + - ruby-version: '3.3' + rails-version: '7.2' + - ruby-version: '3.3' + rails-version: '7.1' - ruby-version: '3.2' rails-version: '7.2' - ruby-version: '3.2' rails-version: '7.1' + - ruby-version: '3.2' + rails-version: '7.0' - ruby-version: '3.1' rails-version: '7.1' - ruby-version: '3.0' - rails-version: '7.1' + rails-version: '7.0' - ruby-version: '2.7' - rails-version: '7.1' - - ruby-version: '2.6' rails-version: '6.1' - ruby-version: '2.6' rails-version: '6.0' - - ruby-version: '2.7' - rails-version: '6.0' - ruby-version: '2.6' rails-version: '5.2' # Old Rubies and Rails From 4f988507ca3924a5e9c8c48a224c469dbab254b9 Mon Sep 17 00:00:00 2001 From: Wasif Hossain Date: Tue, 28 Oct 2025 13:23:08 +0600 Subject: [PATCH 7/8] Bring back few old ruby/rails matrix to CI --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ee3349a0..acd6d9bbe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,10 @@ jobs: rails-version: '7.0' - ruby-version: '2.7' rails-version: '6.1' + - ruby-version: '2.7' + rails-version: '6.0' + - ruby-version: '2.6' + rails-version: '6.1' - ruby-version: '2.6' rails-version: '6.0' - ruby-version: '2.6' From f11a95f6f5624b7bf865cf5fc26cec60df29ff7e Mon Sep 17 00:00:00 2001 From: Tony Drake Date: Sun, 26 Oct 2025 16:40:14 -0400 Subject: [PATCH 8/8] Remove use of ActiveSupport::Configurable Rails 8.1 deprecated `ActiveSupport::Configurable` which this gem currently uses. ``` DEPRECATION WARNING: ActiveSupport::Configurable is deprecated without replacement, and will be removed in Rails 8.2. You can emulate the previous behavior with `class_attribute`. ``` This replaces the use of `ActiveSupport::Configurable` with an `ActiveSupport::OrderedOptions` class attribute. --- lib/active_model/serializer.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/active_model/serializer.rb b/lib/active_model/serializer.rb index 5e3477905..118098f93 100644 --- a/lib/active_model/serializer.rb +++ b/lib/active_model/serializer.rb @@ -13,6 +13,9 @@ # reified when subclassed to decorate a resource. module ActiveModel class Serializer + class_attribute :config + self.config = ActiveSupport::OrderedOptions.new + undef_method :select, :display # These IO methods, which are mixed into Kernel, # sometimes conflict with attribute names. We don't need these IO methods. @@ -30,7 +33,6 @@ class Serializer autoload :HasOneReflection autoload :HasManyReflection end - include ActiveSupport::Configurable include Caching # @param resource [ActiveRecord::Base, ActiveModelSerializers::Model]