Skip to content

Commit

Permalink
Make Rails 7 hack specific to test controller that needs it
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolyon Pawlyn committed Dec 28, 2021
1 parent 5d64851 commit 169d210
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
7 changes: 6 additions & 1 deletion test/action_controller/serialization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions test/support/rails_7_patch.rb

This file was deleted.

1 change: 0 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 169d210

Please sign in to comment.