From b4dc13f1cedc402b6861b2df2696ecbedc2cfd48 Mon Sep 17 00:00:00 2001 From: Frank Rousseau Date: Sun, 5 Nov 2017 22:54:09 +0100 Subject: [PATCH] Fix code styles --- app/controllers/api/v0/comments_controller.rb | 1 - app/controllers/api/v0/posts_controller.rb | 1 - config/routes.rb | 12 ++++---- .../api/comments_controller_spec.rb | 11 +++---- .../api/conversations_controller_spec.rb | 29 +++++++++---------- spec/integration/api/likes_controller_spec.rb | 16 +++++----- .../api/messages_controller_spec.rb | 1 - spec/integration/api/posts_controller_spec.rb | 20 ++++++------- .../api/streams_controller_spec.rb | 8 ++--- spec/services/conversation_service.rb | 2 +- 10 files changed, 49 insertions(+), 52 deletions(-) diff --git a/app/controllers/api/v0/comments_controller.rb b/app/controllers/api/v0/comments_controller.rb index cd84f0e79..dffc21f1b 100644 --- a/app/controllers/api/v0/comments_controller.rb +++ b/app/controllers/api/v0/comments_controller.rb @@ -31,7 +31,6 @@ module Api def comment_service @comment_service ||= CommentService.new(current_user) end - end end end diff --git a/app/controllers/api/v0/posts_controller.rb b/app/controllers/api/v0/posts_controller.rb index a33456afa..3e0fa340c 100644 --- a/app/controllers/api/v0/posts_controller.rb +++ b/app/controllers/api/v0/posts_controller.rb @@ -53,7 +53,6 @@ module Api aspect_ids end end - end end end diff --git a/config/routes.rb b/config/routes.rb index 957b44c69..e74e6968b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -222,14 +222,14 @@ Rails.application.routes.draw do get "podmin", to: "home#podmin" api_version(module: "Api::V0", path: {value: "api/v0"}, default: true) do - match "user", to: "users#show", via: %i(get post) - resources :posts, only: %i(show create destroy) do - resources :comments, only: %i(create destroy) - resources :likes, only: %i(create destroy) + match "user", to: "users#show", via: %i[get post] + resources :posts, only: %i[show create destroy] do + resources :comments, only: %i[create destroy] + resources :likes, only: %i[create destroy] end - resources :conversations, only: %i(show index create destroy) do + resources :conversations, only: %i[show index create destroy] do delete "visibility" => "conversation_visibilities#destroy" - resources :messages, only: %i(index create) + resources :messages, only: %i[index create] end get "activity" => "streams#activity", :as => "activity_stream" get "stream" => "streams#multi", :as => "stream" diff --git a/spec/integration/api/comments_controller_spec.rb b/spec/integration/api/comments_controller_spec.rb index d4cfdf446..5c8bab92c 100644 --- a/spec/integration/api/comments_controller_spec.rb +++ b/spec/integration/api/comments_controller_spec.rb @@ -7,11 +7,12 @@ describe Api::V0::CommentsController do let!(:access_token) { auth.create_access_token.to_s } before do - @status = auth.user.post("Post", + @status = auth.user.post( + "Post", status_message: {text: "This is a status message"}, - public: true, - to: "all", - type: "Post" + public: true, + to: "all", + type: "Post" ) end @@ -31,7 +32,7 @@ describe Api::V0::CommentsController do post( api_v0_post_comments_path(post_id: @status.id), params: { - text: "This is a long comment" * 99_999, + text: "This is a long comment" * 99_999, access_token: access_token } ) diff --git a/spec/integration/api/conversations_controller_spec.rb b/spec/integration/api/conversations_controller_spec.rb index a7e3f7729..569a756bc 100644 --- a/spec/integration/api/conversations_controller_spec.rb +++ b/spec/integration/api/conversations_controller_spec.rb @@ -40,7 +40,7 @@ describe Api::V0::ConversationsController do context "without valid data" do it "fails at creating the conversation" do - post api_v0_conversations_path, params: { access_token: access_token } + post api_v0_conversations_path, params: {access_token: access_token} expect(response.status).to eq 400 end end @@ -62,15 +62,15 @@ describe Api::V0::ConversationsController do end it "returns all the user conversations" do - get api_v0_conversations_path, params: { access_token: access_token } + get api_v0_conversations_path, params: {access_token: access_token} expect(response.status).to eq 200 expect(JSON.parse(response.body).length).to eq 3 end it "returns all the user unread conversations" do get( - api_v0_conversations_path, - params: { unread: true, access_token: access_token } + api_v0_conversations_path, + params: {unread: true, access_token: access_token} ) expect(response.status).to eq 200 expect(JSON.parse(response.body).length).to eq 2 @@ -79,7 +79,7 @@ describe Api::V0::ConversationsController do it "returns all the user conversations after a given date" do get( api_v0_conversations_path, - params: { only_after: @date, access_token: access_token } + params: {only_after: @date, access_token: access_token} ) expect(response.status).to eq 200 expect(JSON.parse(response.body).length).to eq 1 @@ -96,7 +96,7 @@ describe Api::V0::ConversationsController do conversation_guid = JSON.parse(response.body)["conversation"]["guid"] get( api_v0_conversation_path(conversation_guid), - params: { access_token: access_token } + params: {access_token: access_token} ) expect(response.status).to eq 200 conversation = JSON.parse(response.body)["conversation"] @@ -111,7 +111,7 @@ describe Api::V0::ConversationsController do it "returns a not found error (404)" do get( api_v0_conversation_path(42), - params: { access_token: access_token } + params: {access_token: access_token} ) expect(response.status).to eq 404 end @@ -141,17 +141,17 @@ describe Api::V0::ConversationsController do it "destroys the first participant visibility" do delete( api_v0_conversation_path(@conversation_guid), - params: { access_token: access_token } + params: {access_token: access_token} ) expect(response.status).to eq 204 get api_v0_conversation_path( @conversation_guid, - params: { access_token: access_token } + params: {access_token: access_token} ) expect(response.status).to eq 404 get api_v0_conversation_path( @conversation_guid, - params: { access_token: access_token_participant } + params: {access_token: access_token_participant} ) expect(response.status).to eq 200 end @@ -161,17 +161,17 @@ describe Api::V0::ConversationsController do it "destroys the second participant visibilty and the conversation" do delete( api_v0_conversation_path(@conversation_guid), - params: { access_token: access_token } + params: {access_token: access_token} ) delete( api_v0_conversation_path(@conversation_guid), - params: { access_token: access_token_participant } + params: {access_token: access_token_participant} ) expect(response.status).to eq 204 get api_v0_conversation_path( @conversation_guid, - params: { access_token: access_token_participant } + params: {access_token: access_token_participant} ) expect(response.status).to eq 404 @@ -185,7 +185,7 @@ describe Api::V0::ConversationsController do it "returns a not found error (404)" do delete( api_v0_conversation_path(42), - params: { access_token: access_token } + params: {access_token: access_token} ) expect(response.status).to eq 404 end @@ -195,5 +195,4 @@ describe Api::V0::ConversationsController do def conversation_service ConversationService.new(alice) end - end diff --git a/spec/integration/api/likes_controller_spec.rb b/spec/integration/api/likes_controller_spec.rb index 73a0b3320..a5f9472eb 100644 --- a/spec/integration/api/likes_controller_spec.rb +++ b/spec/integration/api/likes_controller_spec.rb @@ -13,8 +13,8 @@ describe Api::V0::LikesController do describe "#create" do it "returns the expected author" do post( - api_v0_post_likes_path(post_id: @status.id), - params: { access_token: access_token } + api_v0_post_likes_path(post_id: @status.id), + params: {access_token: access_token} ) json = JSON.parse(response.body) expect(json["author"]["id"]).to eq(auth.user.person.id) @@ -29,24 +29,24 @@ describe Api::V0::LikesController do describe "#delete" do before do post( - api_v0_post_likes_path(post_id: @status.id), - params: { access_token: access_token } + api_v0_post_likes_path(post_id: @status.id), + params: {access_token: access_token} ) @like_id = JSON.parse(response.body)["id"] end it "succeeds" do delete( - api_v0_post_like_path(post_id: @status.id, id: @like_id), - params: { access_token: access_token } + api_v0_post_like_path(post_id: @status.id, id: @like_id), + params: {access_token: access_token} ) expect(response).to be_success end it "fails on random like id" do delete( - api_v0_post_like_path(post_id: @status.id, id: 99_999_999), - params: { access_token: access_token } + api_v0_post_like_path(post_id: @status.id, id: 99_999_999), + params: {access_token: access_token} ) expect(response.body).to eq("Post or like not found") end diff --git a/spec/integration/api/messages_controller_spec.rb b/spec/integration/api/messages_controller_spec.rb index cb5aa6ece..6bc8edc71 100644 --- a/spec/integration/api/messages_controller_spec.rb +++ b/spec/integration/api/messages_controller_spec.rb @@ -100,5 +100,4 @@ describe Api::V0::MessagesController do end end end - end diff --git a/spec/integration/api/posts_controller_spec.rb b/spec/integration/api/posts_controller_spec.rb index 038668025..cf2aaf25a 100644 --- a/spec/integration/api/posts_controller_spec.rb +++ b/spec/integration/api/posts_controller_spec.rb @@ -24,7 +24,7 @@ describe Api::V0::PostsController do @status = auth_with_read.user.post(:status_message, text: "hello", public: true, to: "all") get( api_v0_post_path(@status.id), - params: {access_token: access_token_with_read} + params: {access_token: access_token_with_read} ) end end @@ -35,7 +35,7 @@ describe Api::V0::PostsController do get( api_v0_post_path(@status.id), params: { - access_token: access_token_with_read, + access_token: access_token_with_read, mark_notifications: "false" } ) @@ -49,21 +49,21 @@ describe Api::V0::PostsController do post( api_v0_posts_path, params: { - access_token: access_token_with_read_and_write, + access_token: access_token_with_read_and_write, status_message: {text: "Hello this is a public post!"}, - aspect_ids: "public" + aspect_ids: "public" } ) - expect(Post.find_by_text("Hello this is a public post!").public).to eq(true) + expect(Post.find_by(text: "Hello this is a public post!").public).to eq(true) end it "creates a private post" do - response = post( + post( api_v0_posts_path, params: { - access_token: access_token_with_read_and_write, + access_token: access_token_with_read_and_write, status_message: {text: "Hello this is a post!"}, - aspect_ids: "1" + aspect_ids: "1" } ) expect(Post.find_by(text: "Hello this is a post!").public).to eq(false) @@ -75,9 +75,9 @@ describe Api::V0::PostsController do post( api_v0_posts_path, params: { - access_token: access_token_with_read, + access_token: access_token_with_read, status_message: {text: "Hello this is a post!"}, - aspect_ids: "public" + aspect_ids: "public" } ) end diff --git a/spec/integration/api/streams_controller_spec.rb b/spec/integration/api/streams_controller_spec.rb index 1177c6571..6acf8c60e 100644 --- a/spec/integration/api/streams_controller_spec.rb +++ b/spec/integration/api/streams_controller_spec.rb @@ -14,16 +14,16 @@ describe Api::V0::PostsController do describe "#aspect" do it "contains expected aspect message" do get( - api_v0_aspects_stream_path(a_ids: [@aspect.id]), - params: {access_token: access_token} + api_v0_aspects_stream_path(a_ids: [@aspect.id]), + params: {access_token: access_token} ) expect(response.body).to include("This is a status message") end it "does not save to requested aspects to session" do get( - api_v0_aspects_stream_path(a_ids: [@aspect.id]), - params: {access_token: access_token} + api_v0_aspects_stream_path(a_ids: [@aspect.id]), + params: {access_token: access_token} ) expect(session[:a_ids]).to be_nil end diff --git a/spec/services/conversation_service.rb b/spec/services/conversation_service.rb index 7a04b3a78..ef301f8f6 100644 --- a/spec/services/conversation_service.rb +++ b/spec/services/conversation_service.rb @@ -104,7 +104,7 @@ describe ConversationService do describe "#get_visibility" do it "returns visibility for current user" do visibility = alice_conversation_service.get_visibility( - @conversation.guid + @conversation.guid ) expect(visibility).to_not be_nil end