Move SerializableResource to ActiveModelSerializers namespace

Ref. https://github.com/rails-api/active_model_serializers/pull/1310
This commit is contained in:
Yohan Robert
2016-03-19 06:13:32 +01:00
parent 874b8cab30
commit 21cb896802
28 changed files with 179 additions and 162 deletions

View File

@@ -1,12 +1,19 @@
require 'test_helper'
module ActiveModel
module ActiveModelSerializers
class SerializableResourceTest < ActiveSupport::TestCase
def setup
@resource = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
@serializer = ProfileSerializer.new(@resource)
@adapter = ActiveModelSerializers::Adapter.create(@serializer)
@serializable_resource = ActiveModel::SerializableResource.new(@resource)
@serializable_resource = SerializableResource.new(@resource)
end
def test_deprecation
assert_output(nil, /deprecated/) do
deprecated_serializable_resource = ActiveModel::SerializableResource.new(@resource)
assert_equal(@serializable_resource.as_json, deprecated_serializable_resource.as_json)
end
end
def test_serializable_resource_delegates_serializable_hash_to_the_adapter
@@ -25,11 +32,11 @@ module ActiveModel
end
def test_use_adapter_with_adapter_option
assert ActiveModel::SerializableResource.new(@resource, { adapter: 'json' }).use_adapter?
assert SerializableResource.new(@resource, { adapter: 'json' }).use_adapter?
end
def test_use_adapter_with_adapter_option_as_false
refute ActiveModel::SerializableResource.new(@resource, { adapter: false }).use_adapter?
refute SerializableResource.new(@resource, { adapter: false }).use_adapter?
end
class SerializableResourceErrorsTest < Minitest::Test
@@ -37,7 +44,7 @@ module ActiveModel
options = nil
resource = ModelWithErrors.new
resource.errors.add(:name, 'must be awesome')
serializable_resource = ActiveModel::SerializableResource.new(
serializable_resource = ActiveModelSerializers::SerializableResource.new(
resource, {
serializer: ActiveModel::Serializer::ErrorSerializer,
adapter: :json_api
@@ -57,7 +64,7 @@ module ActiveModel
resources << resource = ModelWithErrors.new
resource.errors.add(:title, 'must be amazing')
resources << ModelWithErrors.new
serializable_resource = ActiveModel::SerializableResource.new(
serializable_resource = SerializableResource.new(
resources, {
serializer: ActiveModel::Serializer::ErrorsSerializer,
each_serializer: ActiveModel::Serializer::ErrorSerializer,