Fix code styles

This commit is contained in:
Frank Rousseau 2017-11-05 22:54:09 +01:00
parent e6fd043206
commit b4dc13f1ce
10 changed files with 49 additions and 52 deletions

View file

@ -31,7 +31,6 @@ module Api
def comment_service def comment_service
@comment_service ||= CommentService.new(current_user) @comment_service ||= CommentService.new(current_user)
end end
end end
end end
end end

View file

@ -53,7 +53,6 @@ module Api
aspect_ids aspect_ids
end end
end end
end end
end end
end end

View file

@ -222,14 +222,14 @@ Rails.application.routes.draw do
get "podmin", to: "home#podmin" get "podmin", to: "home#podmin"
api_version(module: "Api::V0", path: {value: "api/v0"}, default: true) do api_version(module: "Api::V0", path: {value: "api/v0"}, default: true) do
match "user", to: "users#show", via: %i(get post) match "user", to: "users#show", via: %i[get post]
resources :posts, only: %i(show create destroy) do resources :posts, only: %i[show create destroy] do
resources :comments, only: %i(create destroy) resources :comments, only: %i[create destroy]
resources :likes, only: %i(create destroy) resources :likes, only: %i[create destroy]
end end
resources :conversations, only: %i(show index create destroy) do resources :conversations, only: %i[show index create destroy] do
delete "visibility" => "conversation_visibilities#destroy" delete "visibility" => "conversation_visibilities#destroy"
resources :messages, only: %i(index create) resources :messages, only: %i[index create]
end end
get "activity" => "streams#activity", :as => "activity_stream" get "activity" => "streams#activity", :as => "activity_stream"
get "stream" => "streams#multi", :as => "stream" get "stream" => "streams#multi", :as => "stream"

View file

@ -7,7 +7,8 @@ describe Api::V0::CommentsController do
let!(:access_token) { auth.create_access_token.to_s } let!(:access_token) { auth.create_access_token.to_s }
before do before do
@status = auth.user.post("Post", @status = auth.user.post(
"Post",
status_message: {text: "This is a status message"}, status_message: {text: "This is a status message"},
public: true, public: true,
to: "all", to: "all",

View file

@ -40,7 +40,7 @@ describe Api::V0::ConversationsController do
context "without valid data" do context "without valid data" do
it "fails at creating the conversation" 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 expect(response.status).to eq 400
end end
end end
@ -62,7 +62,7 @@ describe Api::V0::ConversationsController do
end end
it "returns all the user conversations" do 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(response.status).to eq 200
expect(JSON.parse(response.body).length).to eq 3 expect(JSON.parse(response.body).length).to eq 3
end end
@ -70,7 +70,7 @@ describe Api::V0::ConversationsController do
it "returns all the user unread conversations" do it "returns all the user unread conversations" do
get( get(
api_v0_conversations_path, api_v0_conversations_path,
params: { unread: true, access_token: access_token } params: {unread: true, access_token: access_token}
) )
expect(response.status).to eq 200 expect(response.status).to eq 200
expect(JSON.parse(response.body).length).to eq 2 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 it "returns all the user conversations after a given date" do
get( get(
api_v0_conversations_path, 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(response.status).to eq 200
expect(JSON.parse(response.body).length).to eq 1 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"] conversation_guid = JSON.parse(response.body)["conversation"]["guid"]
get( get(
api_v0_conversation_path(conversation_guid), api_v0_conversation_path(conversation_guid),
params: { access_token: access_token } params: {access_token: access_token}
) )
expect(response.status).to eq 200 expect(response.status).to eq 200
conversation = JSON.parse(response.body)["conversation"] conversation = JSON.parse(response.body)["conversation"]
@ -111,7 +111,7 @@ describe Api::V0::ConversationsController do
it "returns a not found error (404)" do it "returns a not found error (404)" do
get( get(
api_v0_conversation_path(42), api_v0_conversation_path(42),
params: { access_token: access_token } params: {access_token: access_token}
) )
expect(response.status).to eq 404 expect(response.status).to eq 404
end end
@ -141,17 +141,17 @@ describe Api::V0::ConversationsController do
it "destroys the first participant visibility" do it "destroys the first participant visibility" do
delete( delete(
api_v0_conversation_path(@conversation_guid), api_v0_conversation_path(@conversation_guid),
params: { access_token: access_token } params: {access_token: access_token}
) )
expect(response.status).to eq 204 expect(response.status).to eq 204
get api_v0_conversation_path( get api_v0_conversation_path(
@conversation_guid, @conversation_guid,
params: { access_token: access_token } params: {access_token: access_token}
) )
expect(response.status).to eq 404 expect(response.status).to eq 404
get api_v0_conversation_path( get api_v0_conversation_path(
@conversation_guid, @conversation_guid,
params: { access_token: access_token_participant } params: {access_token: access_token_participant}
) )
expect(response.status).to eq 200 expect(response.status).to eq 200
end end
@ -161,17 +161,17 @@ describe Api::V0::ConversationsController do
it "destroys the second participant visibilty and the conversation" do it "destroys the second participant visibilty and the conversation" do
delete( delete(
api_v0_conversation_path(@conversation_guid), api_v0_conversation_path(@conversation_guid),
params: { access_token: access_token } params: {access_token: access_token}
) )
delete( delete(
api_v0_conversation_path(@conversation_guid), api_v0_conversation_path(@conversation_guid),
params: { access_token: access_token_participant } params: {access_token: access_token_participant}
) )
expect(response.status).to eq 204 expect(response.status).to eq 204
get api_v0_conversation_path( get api_v0_conversation_path(
@conversation_guid, @conversation_guid,
params: { access_token: access_token_participant } params: {access_token: access_token_participant}
) )
expect(response.status).to eq 404 expect(response.status).to eq 404
@ -185,7 +185,7 @@ describe Api::V0::ConversationsController do
it "returns a not found error (404)" do it "returns a not found error (404)" do
delete( delete(
api_v0_conversation_path(42), api_v0_conversation_path(42),
params: { access_token: access_token } params: {access_token: access_token}
) )
expect(response.status).to eq 404 expect(response.status).to eq 404
end end
@ -195,5 +195,4 @@ describe Api::V0::ConversationsController do
def conversation_service def conversation_service
ConversationService.new(alice) ConversationService.new(alice)
end end
end end

View file

@ -14,7 +14,7 @@ describe Api::V0::LikesController do
it "returns the expected author" do it "returns the expected author" do
post( post(
api_v0_post_likes_path(post_id: @status.id), api_v0_post_likes_path(post_id: @status.id),
params: { access_token: access_token } params: {access_token: access_token}
) )
json = JSON.parse(response.body) json = JSON.parse(response.body)
expect(json["author"]["id"]).to eq(auth.user.person.id) expect(json["author"]["id"]).to eq(auth.user.person.id)
@ -30,7 +30,7 @@ describe Api::V0::LikesController do
before do before do
post( post(
api_v0_post_likes_path(post_id: @status.id), api_v0_post_likes_path(post_id: @status.id),
params: { access_token: access_token } params: {access_token: access_token}
) )
@like_id = JSON.parse(response.body)["id"] @like_id = JSON.parse(response.body)["id"]
end end
@ -38,7 +38,7 @@ describe Api::V0::LikesController do
it "succeeds" do it "succeeds" do
delete( delete(
api_v0_post_like_path(post_id: @status.id, id: @like_id), api_v0_post_like_path(post_id: @status.id, id: @like_id),
params: { access_token: access_token } params: {access_token: access_token}
) )
expect(response).to be_success expect(response).to be_success
end end
@ -46,7 +46,7 @@ describe Api::V0::LikesController do
it "fails on random like id" do it "fails on random like id" do
delete( delete(
api_v0_post_like_path(post_id: @status.id, id: 99_999_999), api_v0_post_like_path(post_id: @status.id, id: 99_999_999),
params: { access_token: access_token } params: {access_token: access_token}
) )
expect(response.body).to eq("Post or like not found") expect(response.body).to eq("Post or like not found")
end end

View file

@ -100,5 +100,4 @@ describe Api::V0::MessagesController do
end end
end end
end end
end end

View file

@ -54,11 +54,11 @@ describe Api::V0::PostsController do
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 end
it "creates a private post" do it "creates a private post" do
response = post( post(
api_v0_posts_path, api_v0_posts_path,
params: { params: {
access_token: access_token_with_read_and_write, access_token: access_token_with_read_and_write,