mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
re: RuboCop - replace rocket style hashes
This commit is contained in:
@@ -23,7 +23,7 @@ module ActiveModelSerializers
|
||||
assert_equal serializable_resource.serializer_instance.object, @resource
|
||||
|
||||
expected_errors_object = {
|
||||
:errors => [
|
||||
errors: [
|
||||
{
|
||||
source: { pointer: '/data/attributes/name' },
|
||||
detail: 'cannot be nil'
|
||||
@@ -48,10 +48,10 @@ module ActiveModelSerializers
|
||||
assert_equal serializable_resource.serializer_instance.object, @resource
|
||||
|
||||
expected_errors_object = {
|
||||
:errors => [
|
||||
{ :source => { :pointer => '/data/attributes/name' }, :detail => 'cannot be nil' },
|
||||
{ :source => { :pointer => '/data/attributes/name' }, :detail => 'must be longer' },
|
||||
{ :source => { :pointer => '/data/attributes/id' }, :detail => 'must be a uuid' }
|
||||
errors: [
|
||||
{ source: { pointer: '/data/attributes/name' }, detail: 'cannot be nil' },
|
||||
{ source: { pointer: '/data/attributes/name' }, detail: 'must be longer' },
|
||||
{ source: { pointer: '/data/attributes/id' }, detail: 'must be a uuid' }
|
||||
]
|
||||
}
|
||||
assert_equal serializable_resource.as_json, expected_errors_object
|
||||
|
||||
@@ -370,7 +370,7 @@ module ActiveModelSerializers
|
||||
expected = [
|
||||
type: 'nested-posts', id: '2',
|
||||
relationships: {
|
||||
:"nested-posts" => {
|
||||
"nested-posts": {
|
||||
data: [
|
||||
{ type: 'nested-posts', id: '1' },
|
||||
{ type: 'nested-posts', id: '2' }
|
||||
|
||||
@@ -82,10 +82,10 @@ module ActiveModelSerializers
|
||||
}
|
||||
},
|
||||
author: 'http://example.com/link_authors/1337',
|
||||
:"link-authors" => 'http://example.com/link_authors',
|
||||
"link-authors": 'http://example.com/link_authors',
|
||||
resource: 'http://example.com/resource',
|
||||
posts: 'http://example.com/link_authors/1337/posts',
|
||||
:"yet-another" => 'http://example.com/resource/1337'
|
||||
"yet-another": 'http://example.com/resource/1337'
|
||||
}
|
||||
assert_equal(expected, hash[:data][:links])
|
||||
end
|
||||
|
||||
@@ -54,7 +54,7 @@ module ActiveModel
|
||||
adapter: :json_api
|
||||
).serializable_hash
|
||||
expected = {
|
||||
:"comments-count" => @post.comments.count
|
||||
"comments-count": @post.comments.count
|
||||
}
|
||||
assert_equal(expected, hash[:data][:meta])
|
||||
end
|
||||
@@ -68,9 +68,9 @@ module ActiveModel
|
||||
adapter: :json_api
|
||||
).serializable_hash
|
||||
expected = {
|
||||
:data => [
|
||||
{ :id => '1337', :type => 'posts', :meta => { :"comments-count" => 0 } },
|
||||
{ :id => '1339', :type => 'posts', :meta => { :"comments-count" => 1 } }
|
||||
data: [
|
||||
{ id: '1337', type: 'posts', meta: { "comments-count": 0 } },
|
||||
{ id: '1339', type: 'posts', meta: { "comments-count": 1 } }
|
||||
]
|
||||
}
|
||||
assert_equal(expected, hash)
|
||||
|
||||
@@ -76,7 +76,7 @@ module ActiveModelSerializers
|
||||
attributes: {
|
||||
title: 'Title 1',
|
||||
body: 'Body 1',
|
||||
:"publish-at" => @publish_at
|
||||
"publish-at": @publish_at
|
||||
},
|
||||
relationships: {
|
||||
author: {
|
||||
@@ -91,10 +91,10 @@ module ActiveModelSerializers
|
||||
},
|
||||
links: {
|
||||
self: 'http://example.com/posts/1337',
|
||||
:"post-authors" => 'http://example.com/posts/1337/authors',
|
||||
:"subscriber-comments" => 'http://example.com/posts/1337/comments'
|
||||
"post-authors": 'http://example.com/posts/1337/authors',
|
||||
"subscriber-comments": 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
meta: { rating: 5, :"favorite-count" => 10 }
|
||||
meta: { rating: 5, "favorite-count": 10 }
|
||||
}
|
||||
}, result)
|
||||
end
|
||||
@@ -185,7 +185,7 @@ module ActiveModelSerializers
|
||||
attributes: {
|
||||
title: 'Title 1',
|
||||
body: 'Body 1',
|
||||
:"publish-at" => @publish_at
|
||||
"publish-at": @publish_at
|
||||
},
|
||||
relationships: {
|
||||
author: {
|
||||
@@ -200,10 +200,10 @@ module ActiveModelSerializers
|
||||
},
|
||||
links: {
|
||||
self: 'http://example.com/posts/1337',
|
||||
:"post-authors" => 'http://example.com/posts/1337/authors',
|
||||
:"subscriber-comments" => 'http://example.com/posts/1337/comments'
|
||||
"post-authors": 'http://example.com/posts/1337/authors',
|
||||
"subscriber-comments": 'http://example.com/posts/1337/comments'
|
||||
},
|
||||
meta: { rating: 5, :"favorite-count" => 10 }
|
||||
meta: { rating: 5, "favorite-count": 10 }
|
||||
}
|
||||
}, result)
|
||||
end
|
||||
@@ -332,14 +332,14 @@ module ActiveModelSerializers
|
||||
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options)
|
||||
result = adapter.serializable_hash
|
||||
expected_errors_object = {
|
||||
:errors => [
|
||||
errors: [
|
||||
{
|
||||
:source => { :pointer => '/data/attributes/published-at' },
|
||||
:detail => 'must be in the future'
|
||||
source: { pointer: '/data/attributes/published-at' },
|
||||
detail: 'must be in the future'
|
||||
},
|
||||
{
|
||||
:source => { :pointer => '/data/attributes/title' },
|
||||
:detail => 'must be longer'
|
||||
source: { pointer: '/data/attributes/title' },
|
||||
detail: 'must be longer'
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -357,14 +357,14 @@ module ActiveModelSerializers
|
||||
adapter.serializable_hash
|
||||
end
|
||||
expected_errors_object = {
|
||||
:Errors => [
|
||||
Errors: [
|
||||
{
|
||||
:Source => { :Pointer => '/data/attributes/PublishedAt' },
|
||||
:Detail => 'must be in the future'
|
||||
Source: { Pointer: '/data/attributes/PublishedAt' },
|
||||
Detail: 'must be in the future'
|
||||
},
|
||||
{
|
||||
:Source => { :Pointer => '/data/attributes/Title' },
|
||||
:Detail => 'must be longer'
|
||||
Source: { Pointer: '/data/attributes/Title' },
|
||||
Detail: 'must be longer'
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -382,14 +382,14 @@ module ActiveModelSerializers
|
||||
adapter.serializable_hash
|
||||
end
|
||||
expected_errors_object = {
|
||||
:Errors => [
|
||||
Errors: [
|
||||
{
|
||||
:Source => { :Pointer => '/data/attributes/PublishedAt' },
|
||||
:Detail => 'must be in the future'
|
||||
Source: { Pointer: '/data/attributes/PublishedAt' },
|
||||
Detail: 'must be in the future'
|
||||
},
|
||||
{
|
||||
:Source => { :Pointer => '/data/attributes/Title' },
|
||||
:Detail => 'must be longer'
|
||||
Source: { Pointer: '/data/attributes/Title' },
|
||||
Detail: 'must be longer'
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -408,14 +408,14 @@ module ActiveModelSerializers
|
||||
result = adapter.serializable_hash
|
||||
|
||||
expected_errors_object = {
|
||||
:errors => [
|
||||
errors: [
|
||||
{
|
||||
:source => { :pointer => '/data/attributes/published-at' },
|
||||
:detail => 'must be in the future'
|
||||
source: { pointer: '/data/attributes/published-at' },
|
||||
detail: 'must be in the future'
|
||||
},
|
||||
{
|
||||
:source => { :pointer => '/data/attributes/title' },
|
||||
:detail => 'must be longer'
|
||||
source: { pointer: '/data/attributes/title' },
|
||||
detail: 'must be longer'
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -434,9 +434,9 @@ module ActiveModelSerializers
|
||||
result = adapter.serializable_hash
|
||||
|
||||
expected_errors_object = {
|
||||
:errors => [
|
||||
{ :source => { :pointer => '/data/attributes/published_at' }, :detail => 'must be in the future' },
|
||||
{ :source => { :pointer => '/data/attributes/title' }, :detail => 'must be longer' }
|
||||
errors: [
|
||||
{ source: { pointer: '/data/attributes/published_at' }, detail: 'must be in the future' },
|
||||
{ source: { pointer: '/data/attributes/title' }, detail: 'must be longer' }
|
||||
]
|
||||
}
|
||||
assert_equal expected_errors_object, result
|
||||
@@ -470,9 +470,9 @@ module ActiveModelSerializers
|
||||
result = adapter.serializable_hash
|
||||
|
||||
expected_errors_object = {
|
||||
:Errors => [
|
||||
{ :Source => { :Pointer => '/data/attributes/PublishedAt' }, :Detail => 'must be in the future' },
|
||||
{ :Source => { :Pointer => '/data/attributes/Title' }, :Detail => 'must be longer' }
|
||||
Errors: [
|
||||
{ Source: { Pointer: '/data/attributes/PublishedAt' }, Detail: 'must be in the future' },
|
||||
{ Source: { Pointer: '/data/attributes/Title' }, Detail: 'must be longer' }
|
||||
]
|
||||
}
|
||||
assert_equal expected_errors_object, result
|
||||
@@ -490,9 +490,9 @@ module ActiveModelSerializers
|
||||
result = adapter.serializable_hash
|
||||
|
||||
expected_errors_object = {
|
||||
:errors => [
|
||||
{ :source => { :pointer => '/data/attributes/publishedAt' }, :detail => 'must be in the future' },
|
||||
{ :source => { :pointer => '/data/attributes/title' }, :detail => 'must be longer' }
|
||||
errors: [
|
||||
{ source: { pointer: '/data/attributes/publishedAt' }, detail: 'must be in the future' },
|
||||
{ source: { pointer: '/data/attributes/title' }, detail: 'must be longer' }
|
||||
]
|
||||
}
|
||||
assert_equal expected_errors_object, result
|
||||
|
||||
Reference in New Issue
Block a user