mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
re: RuboCop - replace rocket style hashes
This commit is contained in:
parent
26aa06284f
commit
800221ed90
@ -1,5 +1,5 @@
|
|||||||
AllCops:
|
AllCops:
|
||||||
TargetRubyVersion: 2.2
|
TargetRubyVersion: 2.1
|
||||||
Exclude:
|
Exclude:
|
||||||
- config/initializers/forbidden_yaml.rb
|
- config/initializers/forbidden_yaml.rb
|
||||||
- !ruby/regexp /(vendor|bundle|bin|db|tmp)\/.*/
|
- !ruby/regexp /(vendor|bundle|bin|db|tmp)\/.*/
|
||||||
|
|||||||
@ -6,7 +6,7 @@ module ActiveModelSerializers
|
|||||||
obj = Object.new
|
obj = Object.new
|
||||||
scenarios = [
|
scenarios = [
|
||||||
{
|
{
|
||||||
value: { "some-key": 'value' },
|
value: { :"some-key" => 'value' },
|
||||||
expected: { SomeKey: 'value' }
|
expected: { SomeKey: 'value' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -72,7 +72,7 @@ module ActiveModelSerializers
|
|||||||
obj = Object.new
|
obj = Object.new
|
||||||
scenarios = [
|
scenarios = [
|
||||||
{
|
{
|
||||||
value: { "some-key": 'value' },
|
value: { :"some-key" => 'value' },
|
||||||
expected: { someKey: 'value' }
|
expected: { someKey: 'value' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -139,7 +139,7 @@ module ActiveModelSerializers
|
|||||||
scenarios = [
|
scenarios = [
|
||||||
{
|
{
|
||||||
value: { some_key: 'value' },
|
value: { some_key: 'value' },
|
||||||
expected: { "some-key": 'value' }
|
expected: { :"some-key" => 'value' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: { 'some_key' => 'value' },
|
value: { 'some_key' => 'value' },
|
||||||
@ -147,7 +147,7 @@ module ActiveModelSerializers
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: { SomeKey: 'value' },
|
value: { SomeKey: 'value' },
|
||||||
expected: { "some-key": 'value' }
|
expected: { :"some-key" => 'value' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: { 'SomeKey' => 'value' },
|
value: { 'SomeKey' => 'value' },
|
||||||
@ -155,7 +155,7 @@ module ActiveModelSerializers
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: { someKey: 'value' },
|
value: { someKey: 'value' },
|
||||||
expected: { "some-key": 'value' }
|
expected: { :"some-key" => 'value' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: { 'someKey' => 'value' },
|
value: { 'someKey' => 'value' },
|
||||||
@ -200,7 +200,7 @@ module ActiveModelSerializers
|
|||||||
obj = Object.new
|
obj = Object.new
|
||||||
scenarios = [
|
scenarios = [
|
||||||
{
|
{
|
||||||
value: { "some-key": 'value' },
|
value: { :"some-key" => 'value' },
|
||||||
expected: { some_key: 'value' }
|
expected: { some_key: 'value' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -63,7 +63,7 @@ module ActiveModelSerializers
|
|||||||
def test_transform_dash
|
def test_transform_dash
|
||||||
mock_request(:dash)
|
mock_request(:dash)
|
||||||
assert_equal({
|
assert_equal({
|
||||||
blog: { id: 1, "special-attribute": 'neat', articles: nil }
|
blog: { id: 1, :"special-attribute" => 'neat', articles: nil }
|
||||||
}, @adapter.serializable_hash)
|
}, @adapter.serializable_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -370,7 +370,7 @@ module ActiveModelSerializers
|
|||||||
expected = [
|
expected = [
|
||||||
type: 'nested-posts', id: '2',
|
type: 'nested-posts', id: '2',
|
||||||
relationships: {
|
relationships: {
|
||||||
"nested-posts": {
|
:"nested-posts" => {
|
||||||
data: [
|
data: [
|
||||||
{ type: 'nested-posts', id: '1' },
|
{ type: 'nested-posts', id: '1' },
|
||||||
{ type: 'nested-posts', id: '2' }
|
{ type: 'nested-posts', id: '2' }
|
||||||
|
|||||||
@ -82,10 +82,10 @@ module ActiveModelSerializers
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
author: 'http://example.com/link_authors/1337',
|
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',
|
resource: 'http://example.com/resource',
|
||||||
posts: 'http://example.com/link_authors/1337/posts',
|
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])
|
assert_equal(expected, hash[:data][:links])
|
||||||
end
|
end
|
||||||
|
|||||||
@ -54,7 +54,7 @@ module ActiveModel
|
|||||||
adapter: :json_api
|
adapter: :json_api
|
||||||
).serializable_hash
|
).serializable_hash
|
||||||
expected = {
|
expected = {
|
||||||
"comments-count": @post.comments.count
|
:"comments-count" => @post.comments.count
|
||||||
}
|
}
|
||||||
assert_equal(expected, hash[:data][:meta])
|
assert_equal(expected, hash[:data][:meta])
|
||||||
end
|
end
|
||||||
@ -69,8 +69,8 @@ module ActiveModel
|
|||||||
).serializable_hash
|
).serializable_hash
|
||||||
expected = {
|
expected = {
|
||||||
data: [
|
data: [
|
||||||
{ id: '1337', type: 'posts', meta: { "comments-count": 0 } },
|
{ id: '1337', type: 'posts', meta: { :"comments-count" => 0 } },
|
||||||
{ id: '1339', type: 'posts', meta: { "comments-count": 1 } }
|
{ id: '1339', type: 'posts', meta: { :"comments-count" => 1 } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
assert_equal(expected, hash)
|
assert_equal(expected, hash)
|
||||||
|
|||||||
@ -76,7 +76,7 @@ module ActiveModelSerializers
|
|||||||
attributes: {
|
attributes: {
|
||||||
title: 'Title 1',
|
title: 'Title 1',
|
||||||
body: 'Body 1',
|
body: 'Body 1',
|
||||||
"publish-at": @publish_at
|
:"publish-at" => @publish_at
|
||||||
},
|
},
|
||||||
relationships: {
|
relationships: {
|
||||||
author: {
|
author: {
|
||||||
@ -91,10 +91,10 @@ module ActiveModelSerializers
|
|||||||
},
|
},
|
||||||
links: {
|
links: {
|
||||||
self: 'http://example.com/posts/1337',
|
self: 'http://example.com/posts/1337',
|
||||||
"post-authors": 'http://example.com/posts/1337/authors',
|
:"post-authors" => 'http://example.com/posts/1337/authors',
|
||||||
"subscriber-comments": 'http://example.com/posts/1337/comments'
|
:"subscriber-comments" => 'http://example.com/posts/1337/comments'
|
||||||
},
|
},
|
||||||
meta: { rating: 5, "favorite-count": 10 }
|
meta: { rating: 5, :"favorite-count" => 10 }
|
||||||
}
|
}
|
||||||
}, result)
|
}, result)
|
||||||
end
|
end
|
||||||
@ -185,7 +185,7 @@ module ActiveModelSerializers
|
|||||||
attributes: {
|
attributes: {
|
||||||
title: 'Title 1',
|
title: 'Title 1',
|
||||||
body: 'Body 1',
|
body: 'Body 1',
|
||||||
"publish-at": @publish_at
|
:"publish-at" => @publish_at
|
||||||
},
|
},
|
||||||
relationships: {
|
relationships: {
|
||||||
author: {
|
author: {
|
||||||
@ -200,10 +200,10 @@ module ActiveModelSerializers
|
|||||||
},
|
},
|
||||||
links: {
|
links: {
|
||||||
self: 'http://example.com/posts/1337',
|
self: 'http://example.com/posts/1337',
|
||||||
"post-authors": 'http://example.com/posts/1337/authors',
|
:"post-authors" => 'http://example.com/posts/1337/authors',
|
||||||
"subscriber-comments": 'http://example.com/posts/1337/comments'
|
:"subscriber-comments" => 'http://example.com/posts/1337/comments'
|
||||||
},
|
},
|
||||||
meta: { rating: 5, "favorite-count": 10 }
|
meta: { rating: 5, :"favorite-count" => 10 }
|
||||||
}
|
}
|
||||||
}, result)
|
}, result)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user