From ba2ee99a7cc08ee5a3f6853e2bb94066d0299999 Mon Sep 17 00:00:00 2001 From: Jolyon Pawlyn Date: Thu, 16 Dec 2021 09:15:31 +0200 Subject: [PATCH 1/6] Relax gem requirement to allow Rails 7 --- .travis.yml | 12 ++++++++++++ active_model_serializers.gemspec | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2853793fc..752be9953 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,8 @@ _rails_supported_versions: - &rails_5_2_jruby RAILS_VERSION=5.2 JRUBY_OPTS='--dev -J-Xmx1024M --debug' - &rails_6_0 RAILS_VERSION=6.0 - &rails_6_0_jruby RAILS_VERSION=6.0 JRUBY_OPTS='--dev -J-Xmx1024M --debug' + - &rails_7_0 RAILS_VERSION=7.0 + - &rails_7_0_jruby RAILS_VERSION=7.0 JRUBY_OPTS='--dev -J-Xmx1024M --debug' - &rails_master RAILS_VERSION=master - &rails_master_jruby RAILS_VERSION=master JRUBY_OPTS='--dev -J-Xmx1024M --debug' @@ -59,6 +61,7 @@ env: - *rails_5_1 - *rails_5_2 - *rails_6_0 + - *rails_7_0 - *rails_master rvm: @@ -87,6 +90,7 @@ jobs: - { rvm: *jruby_9_2, jdk: *jdk_8, env: *rails_5_1_jruby } - { rvm: *jruby_9_2, jdk: *jdk_8, env: *rails_5_2_jruby } - { rvm: *jruby_9_2, jdk: *jdk_8, env: *rails_6_0_jruby } + - { rvm: *jruby_9_2, jdk: *jdk_8, env: *rails_7_0_jruby } - { rvm: *jruby_9_2, jdk: *jdk_8, env: *rails_master_jruby } - { rvm: *jruby_head, jdk: *jdk_8, env: *rails_4_2_jruby } @@ -94,6 +98,7 @@ jobs: - { rvm: *jruby_head, jdk: *jdk_8, env: *rails_5_1_jruby } - { rvm: *jruby_head, jdk: *jdk_8, env: *rails_5_2_jruby } - { rvm: *jruby_head, jdk: *jdk_8, env: *rails_6_0_jruby } + - { rvm: *jruby_head, jdk: *jdk_8, env: *rails_7_0_jruby } - { rvm: *jruby_head, jdk: *jdk_8, env: *rails_master_jruby } exclude: @@ -107,6 +112,13 @@ jobs: - { rvm: *ruby_2_2, env: *rails_6_0 } - { rvm: *ruby_2_3, env: *rails_6_0 } + - { rvm: *ruby_2_1, env: *rails_7_0 } + - { rvm: *ruby_2_2, env: *rails_7_0 } + - { rvm: *ruby_2_3, env: *rails_7_0 } + - { rvm: *ruby_2_4, env: *rails_7_0 } + - { rvm: *ruby_2_5, env: *rails_7_0 } + - { rvm: *ruby_2_6, env: *rails_7_0 } + - { rvm: *ruby_2_1, env: *rails_master } - { rvm: *ruby_2_2, env: *rails_master } - { rvm: *ruby_2_3, env: *rails_master } diff --git a/active_model_serializers.gemspec b/active_model_serializers.gemspec index 50cd71154..471ab06fe 100644 --- a/active_model_serializers.gemspec +++ b/active_model_serializers.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 2.1' - rails_versions = ['>= 4.1', '< 7.0'] + rails_versions = ['>= 4.1', '< 8.0'] spec.add_runtime_dependency 'activemodel', rails_versions # 'activesupport', rails_versions # 'builder' From b6d2c8f0489ea0cd26f20edc74e14c33e40e14c4 Mon Sep 17 00:00:00 2001 From: Jolyon Pawlyn Date: Thu, 16 Dec 2021 12:59:14 +0200 Subject: [PATCH 2/6] Action review comments --- .github/workflows/ci.yml | 4 ++++ active_model_serializers.gemspec | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0455bf25..3abe7987d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,10 @@ jobs: matrix: include: # Recent Rubies and Rails + - ruby-version: '3.0' + rails-version: '7.0' + - ruby-version: '2.7' + rails-version: '7.0' - ruby-version: '2.6' rails-version: '6.1' - ruby-version: '2.6' diff --git a/active_model_serializers.gemspec b/active_model_serializers.gemspec index 471ab06fe..2d1855e8d 100644 --- a/active_model_serializers.gemspec +++ b/active_model_serializers.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 2.1' - rails_versions = ['>= 4.1', '< 8.0'] + rails_versions = ['>= 4.1', '< 7.1'] spec.add_runtime_dependency 'activemodel', rails_versions # 'activesupport', rails_versions # 'builder' From c1acc24b311dc6f993f1ec190b9989311edee876 Mon Sep 17 00:00:00 2001 From: Jolyon Pawlyn Date: Thu, 16 Dec 2021 13:01:15 +0200 Subject: [PATCH 3/6] Rollback redundant travis change --- .travis.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 752be9953..2853793fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,8 +32,6 @@ _rails_supported_versions: - &rails_5_2_jruby RAILS_VERSION=5.2 JRUBY_OPTS='--dev -J-Xmx1024M --debug' - &rails_6_0 RAILS_VERSION=6.0 - &rails_6_0_jruby RAILS_VERSION=6.0 JRUBY_OPTS='--dev -J-Xmx1024M --debug' - - &rails_7_0 RAILS_VERSION=7.0 - - &rails_7_0_jruby RAILS_VERSION=7.0 JRUBY_OPTS='--dev -J-Xmx1024M --debug' - &rails_master RAILS_VERSION=master - &rails_master_jruby RAILS_VERSION=master JRUBY_OPTS='--dev -J-Xmx1024M --debug' @@ -61,7 +59,6 @@ env: - *rails_5_1 - *rails_5_2 - *rails_6_0 - - *rails_7_0 - *rails_master rvm: @@ -90,7 +87,6 @@ jobs: - { rvm: *jruby_9_2, jdk: *jdk_8, env: *rails_5_1_jruby } - { rvm: *jruby_9_2, jdk: *jdk_8, env: *rails_5_2_jruby } - { rvm: *jruby_9_2, jdk: *jdk_8, env: *rails_6_0_jruby } - - { rvm: *jruby_9_2, jdk: *jdk_8, env: *rails_7_0_jruby } - { rvm: *jruby_9_2, jdk: *jdk_8, env: *rails_master_jruby } - { rvm: *jruby_head, jdk: *jdk_8, env: *rails_4_2_jruby } @@ -98,7 +94,6 @@ jobs: - { rvm: *jruby_head, jdk: *jdk_8, env: *rails_5_1_jruby } - { rvm: *jruby_head, jdk: *jdk_8, env: *rails_5_2_jruby } - { rvm: *jruby_head, jdk: *jdk_8, env: *rails_6_0_jruby } - - { rvm: *jruby_head, jdk: *jdk_8, env: *rails_7_0_jruby } - { rvm: *jruby_head, jdk: *jdk_8, env: *rails_master_jruby } exclude: @@ -112,13 +107,6 @@ jobs: - { rvm: *ruby_2_2, env: *rails_6_0 } - { rvm: *ruby_2_3, env: *rails_6_0 } - - { rvm: *ruby_2_1, env: *rails_7_0 } - - { rvm: *ruby_2_2, env: *rails_7_0 } - - { rvm: *ruby_2_3, env: *rails_7_0 } - - { rvm: *ruby_2_4, env: *rails_7_0 } - - { rvm: *ruby_2_5, env: *rails_7_0 } - - { rvm: *ruby_2_6, env: *rails_7_0 } - - { rvm: *ruby_2_1, env: *rails_master } - { rvm: *ruby_2_2, env: *rails_master } - { rvm: *ruby_2_3, env: *rails_master } From 5d64851ad054ecc24bee0371203b6eb0e60d28b2 Mon Sep 17 00:00:00 2001 From: Jolyon Pawlyn Date: Thu, 16 Dec 2021 15:15:40 +0200 Subject: [PATCH 4/6] Prevent the clearing of instance variables after each test request with Rails 7 --- test/support/rails_7_patch.rb | 13 +++++++++++++ test/test_helper.rb | 1 + 2 files changed, 14 insertions(+) create mode 100644 test/support/rails_7_patch.rb diff --git a/test/support/rails_7_patch.rb b/test/support/rails_7_patch.rb new file mode 100644 index 000000000..b2cc74ab2 --- /dev/null +++ b/test/support/rails_7_patch.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# HACK: to prevent the resetting of instance variables after each request in Rails 7 +# see https://github.com/rails/rails/pull/43735 +if Rails::VERSION::MAJOR >= 7 + module ActionController + module Testing + module Functional + def clear_instance_variables_between_requests; end + end + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 7d8ca63e3..00123504e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -49,6 +49,7 @@ def silence_warnings require 'support/rails_app' +require 'support/rails_7_patch' require 'support/ruby_2_6_rails_4_2_patch' # require "rails/test_help" From 169d210187746a92b8eb8b703f76f903ee9197d7 Mon Sep 17 00:00:00 2001 From: Jolyon Pawlyn Date: Tue, 28 Dec 2021 09:08:06 +0000 Subject: [PATCH 5/6] Make Rails 7 hack specific to test controller that needs it --- test/action_controller/serialization_test.rb | 7 ++++++- test/support/rails_7_patch.rb | 13 ------------- test/test_helper.rb | 1 - 3 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 test/support/rails_7_patch.rb diff --git a/test/action_controller/serialization_test.rb b/test/action_controller/serialization_test.rb index 8d360b6f8..2286309b4 100644 --- a/test/action_controller/serialization_test.rb +++ b/test/action_controller/serialization_test.rb @@ -7,6 +7,7 @@ module Serialization class ImplicitSerializerTest < ActionController::TestCase class ImplicitSerializationTestController < ActionController::Base include SerializationTesting + def render_using_implicit_serializer @profile = Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1') render json: @profile @@ -75,8 +76,12 @@ def render_json_array_object_without_serializer render json: [{ error: 'Result is Invalid' }] end + # HACK: to prevent the resetting of instance variables after each request in Rails 7 + # see https://github.com/rails/rails/pull/43735 + def clear_instance_variables_between_requests; end + def update_and_render_object_with_cache_enabled - @post.updated_at = Time.zone.now + @post.updated_at = Time.zone.now # requires hack above to prevent `NoMethodError: undefined method `updated_at=' for nil:NilClass` generate_cached_serializer(@post) render json: @post diff --git a/test/support/rails_7_patch.rb b/test/support/rails_7_patch.rb deleted file mode 100644 index b2cc74ab2..000000000 --- a/test/support/rails_7_patch.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# HACK: to prevent the resetting of instance variables after each request in Rails 7 -# see https://github.com/rails/rails/pull/43735 -if Rails::VERSION::MAJOR >= 7 - module ActionController - module Testing - module Functional - def clear_instance_variables_between_requests; end - end - end - end -end diff --git a/test/test_helper.rb b/test/test_helper.rb index 00123504e..7d8ca63e3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -49,7 +49,6 @@ def silence_warnings require 'support/rails_app' -require 'support/rails_7_patch' require 'support/ruby_2_6_rails_4_2_patch' # require "rails/test_help" From c91c7892dc175e65f09f789c33bdf51bf9dc7508 Mon Sep 17 00:00:00 2001 From: Jolyon Pawlyn Date: Tue, 28 Dec 2021 20:26:01 +0000 Subject: [PATCH 6/6] Add ruby 3.1 and rails 7.0 to ci matrix --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3abe7987d..b02f6a0a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ jobs: matrix: include: # Recent Rubies and Rails + - ruby-version: '3.1' + rails-version: '7.0' - ruby-version: '3.0' rails-version: '7.0' - ruby-version: '2.7'