FIX: Make reply-ids public by fixing a typo (#16137)

…and spec the endpoint
This commit is contained in:
Jarek Radosz 2022-03-08 21:08:15 +01:00 committed by GitHub
parent 6d422a8033
commit bf252752e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -9,7 +9,7 @@ class PostsController < ApplicationController
:by_date,
:short_link,
:reply_history,
:replyIids,
:reply_ids,
:revisions,
:latest_revision,
:expand_embed,

View File

@ -170,6 +170,28 @@ describe PostsController do
end
end
describe '#reply_ids' do
include_examples 'finding and showing post' do
let(:url) { "/posts/#{post.id}/reply-ids.json" }
end
it "returns ids of post's replies" do
post = Fabricate(:post)
reply1 = Fabricate(:post, topic: post.topic, reply_to_post_number: post.post_number)
reply2 = Fabricate(:post, topic: post.topic, reply_to_post_number: post.post_number)
PostReply.create(post_id: post.id, reply_post_id: reply1.id)
PostReply.create(post_id: post.id, reply_post_id: reply2.id)
get "/posts/#{post.id}/reply-ids.json"
expect(response.status).to eq(200)
expect(response.parsed_body).to eq([
{ "id" => reply1.id, "level" => 1 },
{ "id" => reply2.id, "level" => 1 },
])
end
end
describe '#replies' do
include_examples 'finding and showing post' do
let(:url) { "/posts/#{post.id}/replies.json" }