Fix styles for some API controllers
* Comments * Likes * Streams
This commit is contained in:
parent
84f972b368
commit
d03b830b07
6 changed files with 11 additions and 10 deletions
|
|
@ -1,7 +1,6 @@
|
|||
module Api
|
||||
module V0
|
||||
class CommentsController < Api::V0::BaseController
|
||||
|
||||
before_action only: %i(create destroy) do
|
||||
require_access_token %w(read write)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ module Api
|
|||
end
|
||||
|
||||
def destroy
|
||||
@like = Like.find_by_id_and_author_id!(params[:id], current_user.person.id)
|
||||
@like = Like.find_by!(id: params[:id], author_id: current_user.person.id)
|
||||
current_user.retract(@like)
|
||||
render nothing: true, status: 204
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
module Api
|
||||
module V0
|
||||
class StreamsController < Api::V0::BaseController
|
||||
|
||||
before_action do
|
||||
require_access_token %w(read)
|
||||
end
|
||||
|
|
@ -43,7 +42,6 @@ module Api
|
|||
private
|
||||
|
||||
def stream_responder(stream_klass=nil)
|
||||
|
||||
if stream_klass.present?
|
||||
@stream ||= stream_klass.new(current_user, max_time: max_time)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ class PostService
|
|||
service = CommentService.new(post_id: post.id, user: user)
|
||||
@presenter = PostPresenter.new(post, user)
|
||||
@presenter.as_json.tap do |post|
|
||||
post[:interactions] = ({comments: service.comments}).merge!(post[:interactions])
|
||||
comments_hash = {comments: service.comments}
|
||||
post[:interactions] = comments_hash.merge!(post[:interactions])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,10 @@ describe Api::V0::PostsController do
|
|||
|
||||
context "comment too long" do
|
||||
before do
|
||||
post api_v0_post_comments_path(post_id: @status.id), text: "This is a long comment" * 99999, access_token: access_token
|
||||
post(
|
||||
api_v0_post_comments_path(post_id: @status.id),
|
||||
text: "This is a long comment" * 99_999, access_token: access_token
|
||||
)
|
||||
end
|
||||
|
||||
it "fails with appropriate error message" do
|
||||
|
|
@ -46,7 +49,7 @@ describe Api::V0::PostsController do
|
|||
end
|
||||
|
||||
it "fails to delete" do
|
||||
delete api_v0_post_comment_path(id: 1234567), access_token: access_token
|
||||
delete api_v0_post_comment_path(id: 1_234_567), access_token: access_token
|
||||
expect(response.body).to eq("Post or comment not found")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ describe Api::V0::LikesController do
|
|||
end
|
||||
|
||||
it "fails on random post id" do
|
||||
post api_v0_post_likes_path(post_id: 9999999), access_token: access_token
|
||||
post api_v0_post_likes_path(post_id: 99_999_999), access_token: access_token
|
||||
expect(response.body).to eq("Post or like not found")
|
||||
end
|
||||
end
|
||||
|
|
@ -33,7 +33,7 @@ describe Api::V0::LikesController do
|
|||
end
|
||||
|
||||
it "fails on random like id" do
|
||||
delete api_v0_post_like_path(post_id: @status.id, id: 99999999), access_token: access_token
|
||||
delete api_v0_post_like_path(post_id: @status.id, id: 99_999_999), access_token: access_token
|
||||
expect(response.body).to eq("Post or like not found")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue