mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Move SerializableResource to ActiveModelSerializers namespace
Ref. https://github.com/rails-api/active_model_serializers/pull/1310
This commit is contained in:
@@ -57,10 +57,10 @@ module ActiveModelSerializers
|
||||
end
|
||||
|
||||
def test_limiting_fields
|
||||
actual = ActiveModel::SerializableResource.new(
|
||||
actual = ActiveModelSerializers::SerializableResource.new(
|
||||
[@first_post, @second_post], adapter: :json_api,
|
||||
fields: { posts: %w(title comments blog author) })
|
||||
.serializable_hash
|
||||
.serializable_hash
|
||||
expected = [
|
||||
{
|
||||
id: '1',
|
||||
|
||||
@@ -18,7 +18,7 @@ module ActiveModelSerializers
|
||||
|
||||
@resource.errors.add(:name, 'cannot be nil')
|
||||
|
||||
serializable_resource = ActiveModel::SerializableResource.new(@resource, options)
|
||||
serializable_resource = ActiveModelSerializers::SerializableResource.new(@resource, options)
|
||||
assert_equal serializable_resource.serializer_instance.attributes, {}
|
||||
assert_equal serializable_resource.serializer_instance.object, @resource
|
||||
|
||||
@@ -44,7 +44,7 @@ module ActiveModelSerializers
|
||||
@resource.errors.add(:name, 'must be longer')
|
||||
@resource.errors.add(:id, 'must be a uuid')
|
||||
|
||||
serializable_resource = ActiveModel::SerializableResource.new(@resource, options)
|
||||
serializable_resource = ActiveModelSerializers::SerializableResource.new(@resource, options)
|
||||
assert_equal serializable_resource.serializer_instance.attributes, {}
|
||||
assert_equal serializable_resource.serializer_instance.object, @resource
|
||||
|
||||
|
||||
@@ -312,9 +312,9 @@ module ActiveModelSerializers
|
||||
end
|
||||
|
||||
def test_no_duplicates
|
||||
hash = ActiveModel::SerializableResource.new(@post1, adapter: :json_api,
|
||||
include: '*.*')
|
||||
.serializable_hash
|
||||
hash = ActiveModelSerializers::SerializableResource.new(@post1, adapter: :json_api,
|
||||
include: '*.*')
|
||||
.serializable_hash
|
||||
expected = [
|
||||
{
|
||||
type: 'authors', id: '1',
|
||||
@@ -340,10 +340,10 @@ module ActiveModelSerializers
|
||||
end
|
||||
|
||||
def test_no_duplicates_collection
|
||||
hash = ActiveModel::SerializableResource.new(
|
||||
hash = ActiveModelSerializers::SerializableResource.new(
|
||||
[@post1, @post2], adapter: :json_api,
|
||||
include: '*.*')
|
||||
.serializable_hash
|
||||
.serializable_hash
|
||||
expected = [
|
||||
{
|
||||
type: 'authors', id: '1',
|
||||
@@ -361,7 +361,7 @@ module ActiveModelSerializers
|
||||
end
|
||||
|
||||
def test_no_duplicates_global
|
||||
hash = ActiveModel::SerializableResource.new(
|
||||
hash = ActiveModelSerializers::SerializableResource.new(
|
||||
@nestedpost1,
|
||||
adapter: :json_api,
|
||||
include: '*').serializable_hash
|
||||
@@ -380,7 +380,7 @@ module ActiveModelSerializers
|
||||
end
|
||||
|
||||
def test_no_duplicates_collection_global
|
||||
hash = ActiveModel::SerializableResource.new(
|
||||
hash = ActiveModelSerializers::SerializableResource.new(
|
||||
[@nestedpost1, @nestedpost2],
|
||||
adapter: :json_api,
|
||||
include: '*').serializable_hash
|
||||
|
||||
@@ -30,7 +30,7 @@ module ActiveModelSerializers
|
||||
end
|
||||
|
||||
def test_toplevel_links
|
||||
hash = ActiveModel::SerializableResource.new(
|
||||
hash = ActiveModelSerializers::SerializableResource.new(
|
||||
@post,
|
||||
adapter: :json_api,
|
||||
links: {
|
||||
@@ -53,7 +53,7 @@ module ActiveModelSerializers
|
||||
end
|
||||
|
||||
def test_nil_toplevel_links
|
||||
hash = ActiveModel::SerializableResource.new(
|
||||
hash = ActiveModelSerializers::SerializableResource.new(
|
||||
@post,
|
||||
adapter: :json_api,
|
||||
links: nil
|
||||
@@ -62,7 +62,7 @@ module ActiveModelSerializers
|
||||
end
|
||||
|
||||
def test_nil_toplevel_links_json_adapter
|
||||
hash = ActiveModel::SerializableResource.new(
|
||||
hash = ActiveModelSerializers::SerializableResource.new(
|
||||
@post,
|
||||
adapter: :json,
|
||||
links: nil
|
||||
|
||||
@@ -32,7 +32,7 @@ module ActiveModelSerializers
|
||||
|
||||
def load_adapter(paginated_collection, options = {})
|
||||
options = options.merge(adapter: :json_api)
|
||||
ActiveModel::SerializableResource.new(paginated_collection, options)
|
||||
ActiveModelSerializers::SerializableResource.new(paginated_collection, options)
|
||||
end
|
||||
|
||||
def using_kaminari(page = 2)
|
||||
|
||||
@@ -36,7 +36,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def test_meta_hash_object_resource
|
||||
hash = ActiveModel::SerializableResource.new(
|
||||
hash = ActiveModelSerializers::SerializableResource.new(
|
||||
@post,
|
||||
serializer: MetaHashPostSerializer,
|
||||
adapter: :json_api
|
||||
@@ -48,7 +48,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def test_meta_block_object_resource
|
||||
hash = ActiveModel::SerializableResource.new(
|
||||
hash = ActiveModelSerializers::SerializableResource.new(
|
||||
@post,
|
||||
serializer: MetaBlockPostSerializer,
|
||||
adapter: :json_api
|
||||
@@ -62,7 +62,7 @@ module ActiveModel
|
||||
def test_meta_object_resource_in_array
|
||||
post2 = Post.new(id: 1339, comments: [Comment.new])
|
||||
posts = [@post, post2]
|
||||
hash = ActiveModel::SerializableResource.new(
|
||||
hash = ActiveModelSerializers::SerializableResource.new(
|
||||
posts,
|
||||
each_serializer: MetaBlockPostSerializer,
|
||||
adapter: :json_api
|
||||
@@ -77,7 +77,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def test_meta_object_blank_omitted
|
||||
hash = ActiveModel::SerializableResource.new(
|
||||
hash = ActiveModelSerializers::SerializableResource.new(
|
||||
@post,
|
||||
serializer: MetaBlockPostBlankMetaSerializer,
|
||||
adapter: :json_api
|
||||
@@ -86,7 +86,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def test_meta_object_empty_string_omitted
|
||||
hash = ActiveModel::SerializableResource.new(
|
||||
hash = ActiveModelSerializers::SerializableResource.new(
|
||||
@post,
|
||||
serializer: MetaBlockPostEmptyStringSerializer,
|
||||
adapter: :json_api
|
||||
|
||||
Reference in New Issue
Block a user