From 004f1437d8c16556883ba8630121331bb744ef4d Mon Sep 17 00:00:00 2001 From: Alexey Dubovskoy Date: Mon, 20 Jun 2016 20:56:44 +0100 Subject: [PATCH] re: RuboCop - hash indention corrections --- test/adapter/json/transform_test.rb | 28 +- test/adapter/json_api/errors_test.rb | 8 +- test/adapter/json_api/has_many_test.rb | 36 +-- test/adapter/json_api/json_api_test.rb | 10 +- test/adapter/json_api/transform_test.rb | 378 ++++++++++++------------ test/adapter/json_test.rb | 16 +- test/adapter/polymorphic_test.rb | 10 +- test/benchmark/bm_caching.rb | 2 +- 8 files changed, 244 insertions(+), 244 deletions(-) diff --git a/test/adapter/json/transform_test.rb b/test/adapter/json/transform_test.rb index 4a18746d..acef81f9 100644 --- a/test/adapter/json/transform_test.rb +++ b/test/adapter/json/transform_test.rb @@ -28,8 +28,8 @@ module ActiveModelSerializers def test_transform_default mock_request assert_equal({ - blog: { id: 1, special_attribute: 'neat', articles: nil } - }, @adapter.serializable_hash) + blog: { id: 1, special_attribute: 'neat', articles: nil } + }, @adapter.serializable_hash) end def test_transform_global_config @@ -38,8 +38,8 @@ module ActiveModelSerializers @adapter.serializable_hash end assert_equal({ - blog: { id: 1, specialAttribute: 'neat', articles: nil } - }, result) + blog: { id: 1, specialAttribute: 'neat', articles: nil } + }, result) end def test_transform_serialization_ctx_overrides_global_config @@ -48,8 +48,8 @@ module ActiveModelSerializers @adapter.serializable_hash end assert_equal({ - Blog: { Id: 1, SpecialAttribute: 'neat', Articles: nil } - }, result) + Blog: { Id: 1, SpecialAttribute: 'neat', Articles: nil } + }, result) end def test_transform_undefined @@ -63,29 +63,29 @@ module ActiveModelSerializers def test_transform_dash mock_request(:dash) assert_equal({ - blog: { id: 1, :"special-attribute" => 'neat', articles: nil } - }, @adapter.serializable_hash) + blog: { id: 1, :"special-attribute" => 'neat', articles: nil } + }, @adapter.serializable_hash) end def test_transform_unaltered mock_request(:unaltered) assert_equal({ - blog: { id: 1, special_attribute: 'neat', articles: nil } - }, @adapter.serializable_hash) + blog: { id: 1, special_attribute: 'neat', articles: nil } + }, @adapter.serializable_hash) end def test_transform_camel mock_request(:camel) assert_equal({ - Blog: { Id: 1, SpecialAttribute: 'neat', Articles: nil } - }, @adapter.serializable_hash) + Blog: { Id: 1, SpecialAttribute: 'neat', Articles: nil } + }, @adapter.serializable_hash) end def test_transform_camel_lower mock_request(:camel_lower) assert_equal({ - blog: { id: 1, specialAttribute: 'neat', articles: nil } - }, @adapter.serializable_hash) + blog: { id: 1, specialAttribute: 'neat', articles: nil } + }, @adapter.serializable_hash) end end end diff --git a/test/adapter/json_api/errors_test.rb b/test/adapter/json_api/errors_test.rb index d20dc784..fc44ffd0 100644 --- a/test/adapter/json_api/errors_test.rb +++ b/test/adapter/json_api/errors_test.rb @@ -12,8 +12,8 @@ module ActiveModelSerializers def test_active_model_with_error options = { - serializer: ActiveModel::Serializer::ErrorSerializer, - adapter: :json_api + serializer: ActiveModel::Serializer::ErrorSerializer, + adapter: :json_api } @resource.errors.add(:name, 'cannot be nil') @@ -35,8 +35,8 @@ module ActiveModelSerializers def test_active_model_with_multiple_errors options = { - serializer: ActiveModel::Serializer::ErrorSerializer, - adapter: :json_api + serializer: ActiveModel::Serializer::ErrorSerializer, + adapter: :json_api } @resource.errors.add(:name, 'cannot be nil') diff --git a/test/adapter/json_api/has_many_test.rb b/test/adapter/json_api/has_many_test.rb index db75d35c..05a7675a 100644 --- a/test/adapter/json_api/has_many_test.rb +++ b/test/adapter/json_api/has_many_test.rb @@ -112,14 +112,14 @@ module ActiveModelSerializers adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer) assert_equal({ - data: { - id: '1', - type: 'posts', - relationships: { - tags: { data: [@tag.as_json] } - } - } - }, adapter.serializable_hash) + data: { + id: '1', + type: 'posts', + relationships: { + tags: { data: [@tag.as_json] } + } + } + }, adapter.serializable_hash) end def test_has_many_with_virtual_value @@ -127,16 +127,16 @@ module ActiveModelSerializers adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer) assert_equal({ - data: { - id: '1', - type: 'virtual-values', - relationships: { - maker: { data: { type: 'makers', id: '1' } }, - reviews: { data: [{ type: 'reviews', id: '1' }, - { type: 'reviews', id: '2' }] } - } - } - }, adapter.serializable_hash) + data: { + id: '1', + type: 'virtual-values', + relationships: { + maker: { data: { type: 'makers', id: '1' } }, + reviews: { data: [{ type: 'reviews', id: '1' }, + { type: 'reviews', id: '2' }] } + } + } + }, adapter.serializable_hash) end end end diff --git a/test/adapter/json_api/json_api_test.rb b/test/adapter/json_api/json_api_test.rb index 64c1ce8a..cb2ce909 100644 --- a/test/adapter/json_api/json_api_test.rb +++ b/test/adapter/json_api/json_api_test.rb @@ -22,11 +22,11 @@ module ActiveModelSerializers adapter = ActiveModelSerializers::Adapter::JsonApi.new(serializer) assert_equal({ - reviews: { data: [{ type: 'comments', id: '1' }, - { type: 'comments', id: '2' }] }, - writer: { data: { type: 'authors', id: '1' } }, - site: { data: { type: 'blogs', id: '1' } } - }, adapter.serializable_hash[:data][:relationships]) + reviews: { data: [{ type: 'comments', id: '1' }, + { type: 'comments', id: '2' }] }, + writer: { data: { type: 'authors', id: '1' } }, + site: { data: { type: 'blogs', id: '1' } } + }, adapter.serializable_hash[:data][:relationships]) end end end diff --git a/test/adapter/json_api/transform_test.rb b/test/adapter/json_api/transform_test.rb index 2eb2e5ae..217e6599 100644 --- a/test/adapter/json_api/transform_test.rb +++ b/test/adapter/json_api/transform_test.rb @@ -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 diff --git a/test/adapter/json_test.rb b/test/adapter/json_test.rb index e5a5974c..f7f178f8 100644 --- a/test/adapter/json_test.rb +++ b/test/adapter/json_test.rb @@ -32,14 +32,14 @@ module ActiveModelSerializers adapter = ActiveModelSerializers::Adapter::Json.new(serializer) assert_equal({ - id: 1, - reviews: [ - { id: 1, body: 'ZOMG A COMMENT' }, - { id: 2, body: 'ZOMG ANOTHER COMMENT' } - ], - writer: { id: 1, name: 'Steve K.' }, - site: { id: 1, name: 'My Blog!!' } - }, adapter.serializable_hash[:post]) + id: 1, + reviews: [ + { id: 1, body: 'ZOMG A COMMENT' }, + { id: 2, body: 'ZOMG ANOTHER COMMENT' } + ], + writer: { id: 1, name: 'Steve K.' }, + site: { id: 1, name: 'My Blog!!' } + }, adapter.serializable_hash[:post]) end end end diff --git a/test/adapter/polymorphic_test.rb b/test/adapter/polymorphic_test.rb index 91459b01..87d5ff51 100644 --- a/test/adapter/polymorphic_test.rb +++ b/test/adapter/polymorphic_test.rb @@ -27,11 +27,11 @@ module ActiveModel id: 1, title: 'headshot-1.jpg', imageable: { - type: 'employee', - employee: { - id: 42, - name: 'Zoop Zoopler' - } + type: 'employee', + employee: { + id: 42, + name: 'Zoop Zoopler' + } } } diff --git a/test/benchmark/bm_caching.rb b/test/benchmark/bm_caching.rb index 8534dd0e..dce81a7e 100644 --- a/test/benchmark/bm_caching.rb +++ b/test/benchmark/bm_caching.rb @@ -86,7 +86,7 @@ class ApiAssertion } ] } - } + } end def assert_equal(expected, actual, message)