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,11 +7,12 @@ 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",
type: "Post" type: "Post"
) )
end end
@ -31,7 +32,7 @@ describe Api::V0::CommentsController do
post( post(
api_v0_post_comments_path(post_id: @status.id), api_v0_post_comments_path(post_id: @status.id),
params: { params: {
text: "This is a long comment" * 99_999, text: "This is a long comment" * 99_999,
access_token: access_token access_token: access_token
} }
) )

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,15 +62,15 @@ 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
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

@ -13,8 +13,8 @@ describe Api::V0::LikesController do
describe "#create" do describe "#create" 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)
@ -29,24 +29,24 @@ describe Api::V0::LikesController do
describe "#delete" do describe "#delete" 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
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
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

@ -24,7 +24,7 @@ describe Api::V0::PostsController do
@status = auth_with_read.user.post(:status_message, text: "hello", public: true, to: "all") @status = auth_with_read.user.post(:status_message, text: "hello", public: true, to: "all")
get( get(
api_v0_post_path(@status.id), api_v0_post_path(@status.id),
params: {access_token: access_token_with_read} params: {access_token: access_token_with_read}
) )
end end
end end
@ -35,7 +35,7 @@ describe Api::V0::PostsController do
get( get(
api_v0_post_path(@status.id), api_v0_post_path(@status.id),
params: { params: {
access_token: access_token_with_read, access_token: access_token_with_read,
mark_notifications: "false" mark_notifications: "false"
} }
) )
@ -49,21 +49,21 @@ describe Api::V0::PostsController do
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,
status_message: {text: "Hello this is a public post!"}, 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 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,
status_message: {text: "Hello this is a post!"}, 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) expect(Post.find_by(text: "Hello this is a post!").public).to eq(false)
@ -75,9 +75,9 @@ describe Api::V0::PostsController do
post( post(
api_v0_posts_path, api_v0_posts_path,
params: { params: {
access_token: access_token_with_read, access_token: access_token_with_read,
status_message: {text: "Hello this is a post!"}, status_message: {text: "Hello this is a post!"},
aspect_ids: "public" aspect_ids: "public"
} }
) )
end end

View file

@ -14,16 +14,16 @@ describe Api::V0::PostsController do
describe "#aspect" do describe "#aspect" do
it "contains expected aspect message" do it "contains expected aspect message" do
get( get(
api_v0_aspects_stream_path(a_ids: [@aspect.id]), api_v0_aspects_stream_path(a_ids: [@aspect.id]),
params: {access_token: access_token} params: {access_token: access_token}
) )
expect(response.body).to include("This is a status message") expect(response.body).to include("This is a status message")
end end
it "does not save to requested aspects to session" do it "does not save to requested aspects to session" do
get( get(
api_v0_aspects_stream_path(a_ids: [@aspect.id]), api_v0_aspects_stream_path(a_ids: [@aspect.id]),
params: {access_token: access_token} params: {access_token: access_token}
) )
expect(session[:a_ids]).to be_nil expect(session[:a_ids]).to be_nil
end end

View file

@ -104,7 +104,7 @@ describe ConversationService do
describe "#get_visibility" do describe "#get_visibility" do
it "returns visibility for current user" do it "returns visibility for current user" do
visibility = alice_conversation_service.get_visibility( visibility = alice_conversation_service.get_visibility(
@conversation.guid @conversation.guid
) )
expect(visibility).to_not be_nil expect(visibility).to_not be_nil
end end