mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Make Rails 7 hack specific to test controller that needs it
This commit is contained in:
parent
5d64851ad0
commit
169d210187
@ -7,6 +7,7 @@ module ActionController
|
|||||||
class ImplicitSerializerTest < ActionController::TestCase
|
class ImplicitSerializerTest < ActionController::TestCase
|
||||||
class ImplicitSerializationTestController < ActionController::Base
|
class ImplicitSerializationTestController < ActionController::Base
|
||||||
include SerializationTesting
|
include SerializationTesting
|
||||||
|
|
||||||
def render_using_implicit_serializer
|
def render_using_implicit_serializer
|
||||||
@profile = Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
|
@profile = Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
|
||||||
render json: @profile
|
render json: @profile
|
||||||
@ -75,8 +76,12 @@ module ActionController
|
|||||||
render json: [{ error: 'Result is Invalid' }]
|
render json: [{ error: 'Result is Invalid' }]
|
||||||
end
|
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
|
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)
|
generate_cached_serializer(@post)
|
||||||
render json: @post
|
render json: @post
|
||||||
|
|||||||
@ -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
|
|
||||||
@ -49,7 +49,6 @@ end
|
|||||||
|
|
||||||
require 'support/rails_app'
|
require 'support/rails_app'
|
||||||
|
|
||||||
require 'support/rails_7_patch'
|
|
||||||
require 'support/ruby_2_6_rails_4_2_patch'
|
require 'support/ruby_2_6_rails_4_2_patch'
|
||||||
|
|
||||||
# require "rails/test_help"
|
# require "rails/test_help"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user