mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Merge pull request #1161 from bf4/remove_duplicate_test_helper
Remove duplicate test helper
This commit is contained in:
commit
a60e1ea82e
@ -5,6 +5,7 @@ module ActionController
|
||||
class ImplicitSerializerTest < ActionController::TestCase
|
||||
include ActiveSupport::Testing::Stream
|
||||
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
|
||||
@ -123,21 +124,6 @@ module ActionController
|
||||
|
||||
render json: like
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_cached_serializer(obj)
|
||||
ActiveModel::SerializableResource.new(obj).to_json
|
||||
end
|
||||
|
||||
def with_adapter(adapter)
|
||||
old_adapter = ActiveModel::Serializer.config.adapter
|
||||
# JSON-API adapter sets root by default
|
||||
ActiveModel::Serializer.config.adapter = adapter
|
||||
yield
|
||||
ensure
|
||||
ActiveModel::Serializer.config.adapter = old_adapter
|
||||
end
|
||||
end
|
||||
|
||||
tests ImplicitSerializationTestController
|
||||
|
||||
@ -1,8 +1,15 @@
|
||||
class Minitest::Test
|
||||
def before_setup
|
||||
ActionController::Base.cache_store.clear
|
||||
module SerializationTesting
|
||||
private
|
||||
|
||||
def generate_cached_serializer(obj)
|
||||
ActiveModel::SerializableResource.new(obj).to_json
|
||||
end
|
||||
|
||||
# Aliased as :with_configured_adapter to clarify that
|
||||
# this method tests the configured adapter.
|
||||
# When not testing configuration, it may be preferable
|
||||
# to pass in the +adapter+ option to <tt>ActiveModel::SerializableResource</tt>.
|
||||
# e.g ActiveModel::SerializableResource.new(resource, adapter: :json_api)
|
||||
def with_adapter(adapter)
|
||||
old_adapter = ActiveModel::Serializer.config.adapter
|
||||
ActiveModel::Serializer.config.adapter = adapter
|
||||
@ -10,4 +17,13 @@ class Minitest::Test
|
||||
ensure
|
||||
ActiveModel::Serializer.config.adapter = old_adapter
|
||||
end
|
||||
alias_method :with_configured_adapter, :with_adapter
|
||||
end
|
||||
|
||||
class Minitest::Test
|
||||
def before_setup
|
||||
ActionController::Base.cache_store.clear
|
||||
end
|
||||
|
||||
include SerializationTesting
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user