Skip to content

Commit 169d210

Browse files
author
Jolyon Pawlyn
committed
Make Rails 7 hack specific to test controller that needs it
1 parent 5d64851 commit 169d210

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

test/action_controller/serialization_test.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module Serialization
77
class ImplicitSerializerTest < ActionController::TestCase
88
class ImplicitSerializationTestController < ActionController::Base
99
include SerializationTesting
10+
1011
def render_using_implicit_serializer
1112
@profile = Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
1213
render json: @profile
@@ -75,8 +76,12 @@ def render_json_array_object_without_serializer
7576
render json: [{ error: 'Result is Invalid' }]
7677
end
7778

79+
# HACK: to prevent the resetting of instance variables after each request in Rails 7
80+
# see https://github.com/rails/rails/pull/43735
81+
def clear_instance_variables_between_requests; end
82+
7883
def update_and_render_object_with_cache_enabled
79-
@post.updated_at = Time.zone.now
84+
@post.updated_at = Time.zone.now # requires hack above to prevent `NoMethodError: undefined method `updated_at=' for nil:NilClass`
8085

8186
generate_cached_serializer(@post)
8287
render json: @post

test/support/rails_7_patch.rb

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/test_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def silence_warnings
4949

5050
require 'support/rails_app'
5151

52-
require 'support/rails_7_patch'
5352
require 'support/ruby_2_6_rails_4_2_patch'
5453

5554
# require "rails/test_help"

0 commit comments

Comments
 (0)