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
@comment_service ||= CommentService.new(current_user)
end
end
end
end

View file

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

View file

@ -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"

View file

@ -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
}
)

View file

@ -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

View file

@ -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

View file

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

View file

@ -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

View file

@ -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

View file

@ -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