Merge pull request #1161 from bf4/remove_duplicate_test_helper

Remove duplicate test helper
This commit is contained in:
L. Preston Sego III 2015-09-17 07:46:57 -04:00
commit a60e1ea82e
2 changed files with 20 additions and 18 deletions

View File

@ -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

View File

@ -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