Fix API v1 schema for likes on comments and add test
This commit is contained in:
parent
5153534f4c
commit
edfb603965
2 changed files with 26 additions and 3 deletions
|
|
@ -105,9 +105,11 @@
|
|||
"interactions": {
|
||||
"type": "object",
|
||||
"properties" : {
|
||||
"likes" : { "$ref": "https://diaspora.software/api/v1/schema.json#/definitions/likes"},
|
||||
"likes_count" : { "type": "integer"}
|
||||
}
|
||||
"liked" : { "type": "boolean" },
|
||||
"likes_count" : { "type": "integer" }
|
||||
},
|
||||
"required": ["liked", "likes_count"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": ["guid", "created_at", "author", "body", "reported", "interactions"],
|
||||
|
|
|
|||
|
|
@ -159,6 +159,23 @@ describe Api::V1::CommentsController do
|
|||
expect_to_match_json_schema(comments.to_json, "#/definitions/comments")
|
||||
end
|
||||
|
||||
it "retrieves own like state" do
|
||||
like_service.create_for_comment(@comment1.id)
|
||||
|
||||
get(
|
||||
api_v1_post_comments_path(post_id: @status.guid),
|
||||
params: {access_token: access_token}
|
||||
)
|
||||
expect(response.status).to eq(200)
|
||||
comments = response_body(response)
|
||||
expect(comments[0]["interactions"]["liked"]).to eq(true)
|
||||
expect(comments[0]["interactions"]["likes_count"]).to eq(1)
|
||||
expect(comments[1]["interactions"]["liked"]).to eq(false)
|
||||
expect(comments[1]["interactions"]["likes_count"]).to eq(0)
|
||||
|
||||
expect_to_match_json_schema(comments.to_json, "#/definitions/comments")
|
||||
end
|
||||
|
||||
it "returns reported status of a comment" do
|
||||
auth_minimum_scopes.user.reports.create!(item: @comment1, text: "Meh!")
|
||||
get(
|
||||
|
|
@ -443,6 +460,10 @@ describe Api::V1::CommentsController do
|
|||
CommentService.new(user)
|
||||
end
|
||||
|
||||
def like_service(user=auth.user)
|
||||
LikeService.new(user)
|
||||
end
|
||||
|
||||
def response_body(response)
|
||||
JSON.parse(response.body)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue