mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
re: RuboCop - hash indention corrections
This commit is contained in:
@@ -70,33 +70,33 @@ module ActiveModelSerializers
|
||||
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options)
|
||||
result = adapter.serializable_hash
|
||||
assert_equal({
|
||||
data: {
|
||||
id: '1337',
|
||||
type: 'posts',
|
||||
attributes: {
|
||||
title: 'Title 1',
|
||||
body: 'Body 1',
|
||||
:"publish-at" => @publish_at
|
||||
},
|
||||
relationships: {
|
||||
author: {
|
||||
data: { id: '1', type: 'authors' }
|
||||
},
|
||||
comments: {
|
||||
data: [
|
||||
{ id: '7', type: 'comments' },
|
||||
{ id: '12', type: 'comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
links: {
|
||||
self: 'http://example.com/posts/1337',
|
||||
:"post-authors" => 'http://example.com/posts/1337/authors',
|
||||
:"subscriber-comments" => 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
meta: { rating: 5, :"favorite-count" => 10 }
|
||||
}
|
||||
}, result)
|
||||
data: {
|
||||
id: '1337',
|
||||
type: 'posts',
|
||||
attributes: {
|
||||
title: 'Title 1',
|
||||
body: 'Body 1',
|
||||
:"publish-at" => @publish_at
|
||||
},
|
||||
relationships: {
|
||||
author: {
|
||||
data: { id: '1', type: 'authors' }
|
||||
},
|
||||
comments: {
|
||||
data: [
|
||||
{ id: '7', type: 'comments' },
|
||||
{ id: '12', type: 'comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
links: {
|
||||
self: 'http://example.com/posts/1337',
|
||||
:"post-authors" => 'http://example.com/posts/1337/authors',
|
||||
:"subscriber-comments" => 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
meta: { rating: 5, :"favorite-count" => 10 }
|
||||
}
|
||||
}, result)
|
||||
end
|
||||
|
||||
def test_success_document_transform_global_config
|
||||
@@ -107,33 +107,33 @@ module ActiveModelSerializers
|
||||
adapter.serializable_hash
|
||||
end
|
||||
assert_equal({
|
||||
data: {
|
||||
id: '1337',
|
||||
type: 'posts',
|
||||
attributes: {
|
||||
title: 'Title 1',
|
||||
body: 'Body 1',
|
||||
publishAt: @publish_at
|
||||
},
|
||||
relationships: {
|
||||
author: {
|
||||
data: { id: '1', type: 'authors' }
|
||||
},
|
||||
comments: {
|
||||
data: [
|
||||
{ id: '7', type: 'comments' },
|
||||
{ id: '12', type: 'comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
links: {
|
||||
self: 'http://example.com/posts/1337',
|
||||
postAuthors: 'http://example.com/posts/1337/authors',
|
||||
subscriberComments: 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
meta: { rating: 5, favoriteCount: 10 }
|
||||
}
|
||||
}, result)
|
||||
data: {
|
||||
id: '1337',
|
||||
type: 'posts',
|
||||
attributes: {
|
||||
title: 'Title 1',
|
||||
body: 'Body 1',
|
||||
publishAt: @publish_at
|
||||
},
|
||||
relationships: {
|
||||
author: {
|
||||
data: { id: '1', type: 'authors' }
|
||||
},
|
||||
comments: {
|
||||
data: [
|
||||
{ id: '7', type: 'comments' },
|
||||
{ id: '12', type: 'comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
links: {
|
||||
self: 'http://example.com/posts/1337',
|
||||
postAuthors: 'http://example.com/posts/1337/authors',
|
||||
subscriberComments: 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
meta: { rating: 5, favoriteCount: 10 }
|
||||
}
|
||||
}, result)
|
||||
end
|
||||
|
||||
def test_success_doc_transform_serialization_ctx_overrides_global
|
||||
@@ -144,33 +144,33 @@ module ActiveModelSerializers
|
||||
adapter.serializable_hash
|
||||
end
|
||||
assert_equal({
|
||||
Data: {
|
||||
Id: '1337',
|
||||
Type: 'Posts',
|
||||
Attributes: {
|
||||
Title: 'Title 1',
|
||||
Body: 'Body 1',
|
||||
PublishAt: @publish_at
|
||||
},
|
||||
Relationships: {
|
||||
Author: {
|
||||
Data: { Id: '1', Type: 'Authors' }
|
||||
},
|
||||
Comments: {
|
||||
Data: [
|
||||
{ Id: '7', Type: 'Comments' },
|
||||
{ Id: '12', Type: 'Comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
Links: {
|
||||
Self: 'http://example.com/posts/1337',
|
||||
PostAuthors: 'http://example.com/posts/1337/authors',
|
||||
SubscriberComments: 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
Meta: { Rating: 5, FavoriteCount: 10 }
|
||||
}
|
||||
}, result)
|
||||
Data: {
|
||||
Id: '1337',
|
||||
Type: 'Posts',
|
||||
Attributes: {
|
||||
Title: 'Title 1',
|
||||
Body: 'Body 1',
|
||||
PublishAt: @publish_at
|
||||
},
|
||||
Relationships: {
|
||||
Author: {
|
||||
Data: { Id: '1', Type: 'Authors' }
|
||||
},
|
||||
Comments: {
|
||||
Data: [
|
||||
{ Id: '7', Type: 'Comments' },
|
||||
{ Id: '12', Type: 'Comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
Links: {
|
||||
Self: 'http://example.com/posts/1337',
|
||||
PostAuthors: 'http://example.com/posts/1337/authors',
|
||||
SubscriberComments: 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
Meta: { Rating: 5, FavoriteCount: 10 }
|
||||
}
|
||||
}, result)
|
||||
end
|
||||
|
||||
def test_success_document_transform_dash
|
||||
@@ -179,33 +179,33 @@ module ActiveModelSerializers
|
||||
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options)
|
||||
result = adapter.serializable_hash
|
||||
assert_equal({
|
||||
data: {
|
||||
id: '1337',
|
||||
type: 'posts',
|
||||
attributes: {
|
||||
title: 'Title 1',
|
||||
body: 'Body 1',
|
||||
:"publish-at" => @publish_at
|
||||
},
|
||||
relationships: {
|
||||
author: {
|
||||
data: { id: '1', type: 'authors' }
|
||||
},
|
||||
comments: {
|
||||
data: [
|
||||
{ id: '7', type: 'comments' },
|
||||
{ id: '12', type: 'comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
links: {
|
||||
self: 'http://example.com/posts/1337',
|
||||
:"post-authors" => 'http://example.com/posts/1337/authors',
|
||||
:"subscriber-comments" => 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
meta: { rating: 5, :"favorite-count" => 10 }
|
||||
}
|
||||
}, result)
|
||||
data: {
|
||||
id: '1337',
|
||||
type: 'posts',
|
||||
attributes: {
|
||||
title: 'Title 1',
|
||||
body: 'Body 1',
|
||||
:"publish-at" => @publish_at
|
||||
},
|
||||
relationships: {
|
||||
author: {
|
||||
data: { id: '1', type: 'authors' }
|
||||
},
|
||||
comments: {
|
||||
data: [
|
||||
{ id: '7', type: 'comments' },
|
||||
{ id: '12', type: 'comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
links: {
|
||||
self: 'http://example.com/posts/1337',
|
||||
:"post-authors" => 'http://example.com/posts/1337/authors',
|
||||
:"subscriber-comments" => 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
meta: { rating: 5, :"favorite-count" => 10 }
|
||||
}
|
||||
}, result)
|
||||
end
|
||||
|
||||
def test_success_document_transform_unaltered
|
||||
@@ -214,33 +214,33 @@ module ActiveModelSerializers
|
||||
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options)
|
||||
result = adapter.serializable_hash
|
||||
assert_equal({
|
||||
data: {
|
||||
id: '1337',
|
||||
type: 'posts',
|
||||
attributes: {
|
||||
title: 'Title 1',
|
||||
body: 'Body 1',
|
||||
publish_at: @publish_at
|
||||
},
|
||||
relationships: {
|
||||
author: {
|
||||
data: { id: '1', type: 'authors' }
|
||||
},
|
||||
comments: {
|
||||
data: [
|
||||
{ id: '7', type: 'comments' },
|
||||
{ id: '12', type: 'comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
links: {
|
||||
self: 'http://example.com/posts/1337',
|
||||
post_authors: 'http://example.com/posts/1337/authors',
|
||||
subscriber_comments: 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
meta: { rating: 5, favorite_count: 10 }
|
||||
}
|
||||
}, result)
|
||||
data: {
|
||||
id: '1337',
|
||||
type: 'posts',
|
||||
attributes: {
|
||||
title: 'Title 1',
|
||||
body: 'Body 1',
|
||||
publish_at: @publish_at
|
||||
},
|
||||
relationships: {
|
||||
author: {
|
||||
data: { id: '1', type: 'authors' }
|
||||
},
|
||||
comments: {
|
||||
data: [
|
||||
{ id: '7', type: 'comments' },
|
||||
{ id: '12', type: 'comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
links: {
|
||||
self: 'http://example.com/posts/1337',
|
||||
post_authors: 'http://example.com/posts/1337/authors',
|
||||
subscriber_comments: 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
meta: { rating: 5, favorite_count: 10 }
|
||||
}
|
||||
}, result)
|
||||
end
|
||||
|
||||
def test_success_document_transform_undefined
|
||||
@@ -259,33 +259,33 @@ module ActiveModelSerializers
|
||||
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options)
|
||||
result = adapter.serializable_hash
|
||||
assert_equal({
|
||||
Data: {
|
||||
Id: '1337',
|
||||
Type: 'Posts',
|
||||
Attributes: {
|
||||
Title: 'Title 1',
|
||||
Body: 'Body 1',
|
||||
PublishAt: @publish_at
|
||||
},
|
||||
Relationships: {
|
||||
Author: {
|
||||
Data: { Id: '1', Type: 'Authors' }
|
||||
},
|
||||
Comments: {
|
||||
Data: [
|
||||
{ Id: '7', Type: 'Comments' },
|
||||
{ Id: '12', Type: 'Comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
Links: {
|
||||
Self: 'http://example.com/posts/1337',
|
||||
PostAuthors: 'http://example.com/posts/1337/authors',
|
||||
SubscriberComments: 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
Meta: { Rating: 5, FavoriteCount: 10 }
|
||||
}
|
||||
}, result)
|
||||
Data: {
|
||||
Id: '1337',
|
||||
Type: 'Posts',
|
||||
Attributes: {
|
||||
Title: 'Title 1',
|
||||
Body: 'Body 1',
|
||||
PublishAt: @publish_at
|
||||
},
|
||||
Relationships: {
|
||||
Author: {
|
||||
Data: { Id: '1', Type: 'Authors' }
|
||||
},
|
||||
Comments: {
|
||||
Data: [
|
||||
{ Id: '7', Type: 'Comments' },
|
||||
{ Id: '12', Type: 'Comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
Links: {
|
||||
Self: 'http://example.com/posts/1337',
|
||||
PostAuthors: 'http://example.com/posts/1337/authors',
|
||||
SubscriberComments: 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
Meta: { Rating: 5, FavoriteCount: 10 }
|
||||
}
|
||||
}, result)
|
||||
end
|
||||
|
||||
def test_success_document_transform_camel_lower
|
||||
@@ -294,33 +294,33 @@ module ActiveModelSerializers
|
||||
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options)
|
||||
result = adapter.serializable_hash
|
||||
assert_equal({
|
||||
data: {
|
||||
id: '1337',
|
||||
type: 'posts',
|
||||
attributes: {
|
||||
title: 'Title 1',
|
||||
body: 'Body 1',
|
||||
publishAt: @publish_at
|
||||
},
|
||||
relationships: {
|
||||
author: {
|
||||
data: { id: '1', type: 'authors' }
|
||||
},
|
||||
comments: {
|
||||
data: [
|
||||
{ id: '7', type: 'comments' },
|
||||
{ id: '12', type: 'comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
links: {
|
||||
self: 'http://example.com/posts/1337',
|
||||
postAuthors: 'http://example.com/posts/1337/authors',
|
||||
subscriberComments: 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
meta: { rating: 5, favoriteCount: 10 }
|
||||
}
|
||||
}, result)
|
||||
data: {
|
||||
id: '1337',
|
||||
type: 'posts',
|
||||
attributes: {
|
||||
title: 'Title 1',
|
||||
body: 'Body 1',
|
||||
publishAt: @publish_at
|
||||
},
|
||||
relationships: {
|
||||
author: {
|
||||
data: { id: '1', type: 'authors' }
|
||||
},
|
||||
comments: {
|
||||
data: [
|
||||
{ id: '7', type: 'comments' },
|
||||
{ id: '12', type: 'comments' }
|
||||
]
|
||||
}
|
||||
},
|
||||
links: {
|
||||
self: 'http://example.com/posts/1337',
|
||||
postAuthors: 'http://example.com/posts/1337/authors',
|
||||
subscriberComments: 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
meta: { rating: 5, favoriteCount: 10 }
|
||||
}
|
||||
}, result)
|
||||
end
|
||||
|
||||
def test_error_document_transform_default
|
||||
|
||||
Reference in New Issue
Block a user