re: RuboCop - hash indention corrections

This commit is contained in:
Alexey Dubovskoy 2016-06-20 20:56:44 +01:00
parent f15f6850de
commit 004f1437d8
8 changed files with 244 additions and 244 deletions

View File

@ -28,8 +28,8 @@ module ActiveModelSerializers
def test_transform_default def test_transform_default
mock_request mock_request
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
def test_transform_global_config def test_transform_global_config
@ -38,8 +38,8 @@ module ActiveModelSerializers
@adapter.serializable_hash @adapter.serializable_hash
end end
assert_equal({ assert_equal({
blog: { id: 1, specialAttribute: 'neat', articles: nil } blog: { id: 1, specialAttribute: 'neat', articles: nil }
}, result) }, result)
end end
def test_transform_serialization_ctx_overrides_global_config def test_transform_serialization_ctx_overrides_global_config
@ -48,8 +48,8 @@ module ActiveModelSerializers
@adapter.serializable_hash @adapter.serializable_hash
end end
assert_equal({ assert_equal({
Blog: { Id: 1, SpecialAttribute: 'neat', Articles: nil } Blog: { Id: 1, SpecialAttribute: 'neat', Articles: nil }
}, result) }, result)
end end
def test_transform_undefined def test_transform_undefined
@ -63,29 +63,29 @@ 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
def test_transform_unaltered def test_transform_unaltered
mock_request(:unaltered) mock_request(:unaltered)
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
def test_transform_camel def test_transform_camel
mock_request(:camel) mock_request(:camel)
assert_equal({ assert_equal({
Blog: { Id: 1, SpecialAttribute: 'neat', Articles: nil } Blog: { Id: 1, SpecialAttribute: 'neat', Articles: nil }
}, @adapter.serializable_hash) }, @adapter.serializable_hash)
end end
def test_transform_camel_lower def test_transform_camel_lower
mock_request(:camel_lower) mock_request(:camel_lower)
assert_equal({ assert_equal({
blog: { id: 1, specialAttribute: 'neat', articles: nil } blog: { id: 1, specialAttribute: 'neat', articles: nil }
}, @adapter.serializable_hash) }, @adapter.serializable_hash)
end end
end end
end end

View File

@ -12,8 +12,8 @@ module ActiveModelSerializers
def test_active_model_with_error def test_active_model_with_error
options = { options = {
serializer: ActiveModel::Serializer::ErrorSerializer, serializer: ActiveModel::Serializer::ErrorSerializer,
adapter: :json_api adapter: :json_api
} }
@resource.errors.add(:name, 'cannot be nil') @resource.errors.add(:name, 'cannot be nil')
@ -35,8 +35,8 @@ module ActiveModelSerializers
def test_active_model_with_multiple_errors def test_active_model_with_multiple_errors
options = { options = {
serializer: ActiveModel::Serializer::ErrorSerializer, serializer: ActiveModel::Serializer::ErrorSerializer,
adapter: :json_api adapter: :json_api
} }
@resource.errors.add(:name, 'cannot be nil') @resource.errors.add(:name, 'cannot be nil')

View File

@ -112,14 +112,14 @@ module ActiveModelSerializers
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer) adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer)
assert_equal({ assert_equal({
data: { data: {
id: '1', id: '1',
type: 'posts', type: 'posts',
relationships: { relationships: {
tags: { data: [@tag.as_json] } tags: { data: [@tag.as_json] }
} }
} }
}, adapter.serializable_hash) }, adapter.serializable_hash)
end end
def test_has_many_with_virtual_value def test_has_many_with_virtual_value
@ -127,16 +127,16 @@ module ActiveModelSerializers
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer) adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer)
assert_equal({ assert_equal({
data: { data: {
id: '1', id: '1',
type: 'virtual-values', type: 'virtual-values',
relationships: { relationships: {
maker: { data: { type: 'makers', id: '1' } }, maker: { data: { type: 'makers', id: '1' } },
reviews: { data: [{ type: 'reviews', id: '1' }, reviews: { data: [{ type: 'reviews', id: '1' },
{ type: 'reviews', id: '2' }] } { type: 'reviews', id: '2' }] }
} }
} }
}, adapter.serializable_hash) }, adapter.serializable_hash)
end end
end end
end end

View File

@ -22,11 +22,11 @@ module ActiveModelSerializers
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer) adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer)
assert_equal({ assert_equal({
reviews: { data: [{ type: 'comments', id: '1' }, reviews: { data: [{ type: 'comments', id: '1' },
{ type: 'comments', id: '2' }] }, { type: 'comments', id: '2' }] },
writer: { data: { type: 'authors', id: '1' } }, writer: { data: { type: 'authors', id: '1' } },
site: { data: { type: 'blogs', id: '1' } } site: { data: { type: 'blogs', id: '1' } }
}, adapter.serializable_hash[:data][:relationships]) }, adapter.serializable_hash[:data][:relationships])
end end
end end
end end

View File

@ -70,33 +70,33 @@ module ActiveModelSerializers
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options) adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options)
result = adapter.serializable_hash result = adapter.serializable_hash
assert_equal({ assert_equal({
data: { data: {
id: '1337', id: '1337',
type: 'posts', type: 'posts',
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: {
data: { id: '1', type: 'authors' } data: { id: '1', type: 'authors' }
}, },
comments: { comments: {
data: [ data: [
{ id: '7', type: 'comments' }, { id: '7', type: 'comments' },
{ id: '12', type: 'comments' } { id: '12', type: 'comments' }
] ]
} }
}, },
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
def test_success_document_transform_global_config def test_success_document_transform_global_config
@ -107,33 +107,33 @@ module ActiveModelSerializers
adapter.serializable_hash adapter.serializable_hash
end end
assert_equal({ assert_equal({
data: { data: {
id: '1337', id: '1337',
type: 'posts', type: 'posts',
attributes: { attributes: {
title: 'Title 1', title: 'Title 1',
body: 'Body 1', body: 'Body 1',
publishAt: @publish_at publishAt: @publish_at
}, },
relationships: { relationships: {
author: { author: {
data: { id: '1', type: 'authors' } data: { id: '1', type: 'authors' }
}, },
comments: { comments: {
data: [ data: [
{ id: '7', type: 'comments' }, { id: '7', type: 'comments' },
{ id: '12', type: 'comments' } { id: '12', type: 'comments' }
] ]
} }
}, },
links: { links: {
self: 'http://example.com/posts/1337', self: 'http://example.com/posts/1337',
postAuthors: 'http://example.com/posts/1337/authors', postAuthors: 'http://example.com/posts/1337/authors',
subscriberComments: 'http://example.com/posts/1337/comments' subscriberComments: 'http://example.com/posts/1337/comments'
}, },
meta: { rating: 5, favoriteCount: 10 } meta: { rating: 5, favoriteCount: 10 }
} }
}, result) }, result)
end end
def test_success_doc_transform_serialization_ctx_overrides_global def test_success_doc_transform_serialization_ctx_overrides_global
@ -144,33 +144,33 @@ module ActiveModelSerializers
adapter.serializable_hash adapter.serializable_hash
end end
assert_equal({ assert_equal({
Data: { Data: {
Id: '1337', Id: '1337',
Type: 'Posts', Type: 'Posts',
Attributes: { Attributes: {
Title: 'Title 1', Title: 'Title 1',
Body: 'Body 1', Body: 'Body 1',
PublishAt: @publish_at PublishAt: @publish_at
}, },
Relationships: { Relationships: {
Author: { Author: {
Data: { Id: '1', Type: 'Authors' } Data: { Id: '1', Type: 'Authors' }
}, },
Comments: { Comments: {
Data: [ Data: [
{ Id: '7', Type: 'Comments' }, { Id: '7', Type: 'Comments' },
{ Id: '12', Type: 'Comments' } { Id: '12', Type: 'Comments' }
] ]
} }
}, },
Links: { Links: {
Self: 'http://example.com/posts/1337', Self: 'http://example.com/posts/1337',
PostAuthors: 'http://example.com/posts/1337/authors', PostAuthors: 'http://example.com/posts/1337/authors',
SubscriberComments: 'http://example.com/posts/1337/comments' SubscriberComments: 'http://example.com/posts/1337/comments'
}, },
Meta: { Rating: 5, FavoriteCount: 10 } Meta: { Rating: 5, FavoriteCount: 10 }
} }
}, result) }, result)
end end
def test_success_document_transform_dash def test_success_document_transform_dash
@ -179,33 +179,33 @@ module ActiveModelSerializers
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options) adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options)
result = adapter.serializable_hash result = adapter.serializable_hash
assert_equal({ assert_equal({
data: { data: {
id: '1337', id: '1337',
type: 'posts', type: 'posts',
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: {
data: { id: '1', type: 'authors' } data: { id: '1', type: 'authors' }
}, },
comments: { comments: {
data: [ data: [
{ id: '7', type: 'comments' }, { id: '7', type: 'comments' },
{ id: '12', type: 'comments' } { id: '12', type: 'comments' }
] ]
} }
}, },
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
def test_success_document_transform_unaltered def test_success_document_transform_unaltered
@ -214,33 +214,33 @@ module ActiveModelSerializers
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options) adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options)
result = adapter.serializable_hash result = adapter.serializable_hash
assert_equal({ assert_equal({
data: { data: {
id: '1337', id: '1337',
type: 'posts', type: 'posts',
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: {
data: { id: '1', type: 'authors' } data: { id: '1', type: 'authors' }
}, },
comments: { comments: {
data: [ data: [
{ id: '7', type: 'comments' }, { id: '7', type: 'comments' },
{ id: '12', type: 'comments' } { id: '12', type: 'comments' }
] ]
} }
}, },
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
def test_success_document_transform_undefined def test_success_document_transform_undefined
@ -259,33 +259,33 @@ module ActiveModelSerializers
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options) adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options)
result = adapter.serializable_hash result = adapter.serializable_hash
assert_equal({ assert_equal({
Data: { Data: {
Id: '1337', Id: '1337',
Type: 'Posts', Type: 'Posts',
Attributes: { Attributes: {
Title: 'Title 1', Title: 'Title 1',
Body: 'Body 1', Body: 'Body 1',
PublishAt: @publish_at PublishAt: @publish_at
}, },
Relationships: { Relationships: {
Author: { Author: {
Data: { Id: '1', Type: 'Authors' } Data: { Id: '1', Type: 'Authors' }
}, },
Comments: { Comments: {
Data: [ Data: [
{ Id: '7', Type: 'Comments' }, { Id: '7', Type: 'Comments' },
{ Id: '12', Type: 'Comments' } { Id: '12', Type: 'Comments' }
] ]
} }
}, },
Links: { Links: {
Self: 'http://example.com/posts/1337', Self: 'http://example.com/posts/1337',
PostAuthors: 'http://example.com/posts/1337/authors', PostAuthors: 'http://example.com/posts/1337/authors',
SubscriberComments: 'http://example.com/posts/1337/comments' SubscriberComments: 'http://example.com/posts/1337/comments'
}, },
Meta: { Rating: 5, FavoriteCount: 10 } Meta: { Rating: 5, FavoriteCount: 10 }
} }
}, result) }, result)
end end
def test_success_document_transform_camel_lower def test_success_document_transform_camel_lower
@ -294,33 +294,33 @@ module ActiveModelSerializers
adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options) adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer, @options)
result = adapter.serializable_hash result = adapter.serializable_hash
assert_equal({ assert_equal({
data: { data: {
id: '1337', id: '1337',
type: 'posts', type: 'posts',
attributes: { attributes: {
title: 'Title 1', title: 'Title 1',
body: 'Body 1', body: 'Body 1',
publishAt: @publish_at publishAt: @publish_at
}, },
relationships: { relationships: {
author: { author: {
data: { id: '1', type: 'authors' } data: { id: '1', type: 'authors' }
}, },
comments: { comments: {
data: [ data: [
{ id: '7', type: 'comments' }, { id: '7', type: 'comments' },
{ id: '12', type: 'comments' } { id: '12', type: 'comments' }
] ]
} }
}, },
links: { links: {
self: 'http://example.com/posts/1337', self: 'http://example.com/posts/1337',
postAuthors: 'http://example.com/posts/1337/authors', postAuthors: 'http://example.com/posts/1337/authors',
subscriberComments: 'http://example.com/posts/1337/comments' subscriberComments: 'http://example.com/posts/1337/comments'
}, },
meta: { rating: 5, favoriteCount: 10 } meta: { rating: 5, favoriteCount: 10 }
} }
}, result) }, result)
end end
def test_error_document_transform_default def test_error_document_transform_default

View File

@ -32,14 +32,14 @@ module ActiveModelSerializers
adapter = ActiveModelSerializers::Adapter::Json.new(serializer) adapter = ActiveModelSerializers::Adapter::Json.new(serializer)
assert_equal({ assert_equal({
id: 1, id: 1,
reviews: [ reviews: [
{ id: 1, body: 'ZOMG A COMMENT' }, { id: 1, body: 'ZOMG A COMMENT' },
{ id: 2, body: 'ZOMG ANOTHER COMMENT' } { id: 2, body: 'ZOMG ANOTHER COMMENT' }
], ],
writer: { id: 1, name: 'Steve K.' }, writer: { id: 1, name: 'Steve K.' },
site: { id: 1, name: 'My Blog!!' } site: { id: 1, name: 'My Blog!!' }
}, adapter.serializable_hash[:post]) }, adapter.serializable_hash[:post])
end end
end end
end end

View File

@ -27,11 +27,11 @@ module ActiveModel
id: 1, id: 1,
title: 'headshot-1.jpg', title: 'headshot-1.jpg',
imageable: { imageable: {
type: 'employee', type: 'employee',
employee: { employee: {
id: 42, id: 42,
name: 'Zoop Zoopler' name: 'Zoop Zoopler'
} }
} }
} }

View File

@ -86,7 +86,7 @@ class ApiAssertion
} }
] ]
} }
} }
end end
def assert_equal(expected, actual, message) def assert_equal(expected, actual, message)