Remove :id/merge_requests/:merge_request_iid/comments
endpoints
Comments for a merge request should be obtained to the `notes` endpoint.
This commit is contained in:
parent
b941b0ebf5
commit
d536d9590b
2 changed files with 0 additions and 93 deletions
|
@ -226,41 +226,6 @@ module API
|
||||||
.cancel(merge_request)
|
.cancel(merge_request)
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Get the comments of a merge request' do
|
|
||||||
success Entities::MRNote
|
|
||||||
end
|
|
||||||
params do
|
|
||||||
use :pagination
|
|
||||||
end
|
|
||||||
get ':id/merge_requests/:merge_request_iid/comments' do
|
|
||||||
merge_request = find_merge_request_with_access(params[:merge_request_iid])
|
|
||||||
present paginate(merge_request.notes.fresh), with: Entities::MRNote
|
|
||||||
end
|
|
||||||
|
|
||||||
desc 'Post a comment to a merge request' do
|
|
||||||
success Entities::MRNote
|
|
||||||
end
|
|
||||||
params do
|
|
||||||
requires :note, type: String, desc: 'The text of the comment'
|
|
||||||
end
|
|
||||||
post ':id/merge_requests/:merge_request_iid/comments' do
|
|
||||||
merge_request = find_merge_request_with_access(params[:merge_request_iid], :create_note)
|
|
||||||
|
|
||||||
opts = {
|
|
||||||
note: params[:note],
|
|
||||||
noteable_type: 'MergeRequest',
|
|
||||||
noteable_id: merge_request.id
|
|
||||||
}
|
|
||||||
|
|
||||||
note = ::Notes::CreateService.new(user_project, current_user, opts).execute
|
|
||||||
|
|
||||||
if note.save
|
|
||||||
present note, with: Entities::MRNote
|
|
||||||
else
|
|
||||||
render_api_error!("Failed to save note #{note.errors.messages}", 400)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc 'List issues that will be closed on merge' do
|
desc 'List issues that will be closed on merge' do
|
||||||
success Entities::MRNote
|
success Entities::MRNote
|
||||||
end
|
end
|
||||||
|
|
|
@ -623,64 +623,6 @@ describe API::MergeRequests, api: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "POST /projects/:id/merge_requests/:merge_request_iid/comments" do
|
|
||||||
it "returns comment" do
|
|
||||||
original_count = merge_request.notes.size
|
|
||||||
|
|
||||||
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/comments", user), note: "My comment"
|
|
||||||
|
|
||||||
expect(response).to have_http_status(201)
|
|
||||||
expect(json_response['note']).to eq('My comment')
|
|
||||||
expect(json_response['author']['name']).to eq(user.name)
|
|
||||||
expect(json_response['author']['username']).to eq(user.username)
|
|
||||||
expect(merge_request.reload.notes.size).to eq(original_count + 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns 400 if note is missing" do
|
|
||||||
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/comments", user)
|
|
||||||
expect(response).to have_http_status(400)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns 404 if merge request iid is invalid" do
|
|
||||||
post api("/projects/#{project.id}/merge_requests/404/comments", user),
|
|
||||||
note: 'My comment'
|
|
||||||
expect(response).to have_http_status(404)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns 404 if merge request id is used instead of iid" do
|
|
||||||
post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user),
|
|
||||||
note: 'My comment'
|
|
||||||
expect(response).to have_http_status(404)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "GET :id/merge_requests/:merge_request_iid/comments" do
|
|
||||||
let!(:note) { create(:note_on_merge_request, author: user, project: project, noteable: merge_request, note: "a comment on a MR") }
|
|
||||||
let!(:note2) { create(:note_on_merge_request, author: user, project: project, noteable: merge_request, note: "another comment on a MR") }
|
|
||||||
|
|
||||||
it "returns merge_request comments ordered by created_at" do
|
|
||||||
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/comments", user)
|
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
|
||||||
expect(response).to include_pagination_headers
|
|
||||||
expect(json_response).to be_an Array
|
|
||||||
expect(json_response.length).to eq(2)
|
|
||||||
expect(json_response.first['note']).to eq("a comment on a MR")
|
|
||||||
expect(json_response.first['author']['id']).to eq(user.id)
|
|
||||||
expect(json_response.last['note']).to eq("another comment on a MR")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns a 404 error if merge_request_iid is invalid" do
|
|
||||||
get api("/projects/#{project.id}/merge_requests/999/comments", user)
|
|
||||||
expect(response).to have_http_status(404)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns a 404 error if merge_request id is used instead of iid" do
|
|
||||||
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user)
|
|
||||||
expect(response).to have_http_status(404)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET :id/merge_requests/:merge_request_iid/closes_issues' do
|
describe 'GET :id/merge_requests/:merge_request_iid/closes_issues' do
|
||||||
it 'returns the issue that will be closed on merge' do
|
it 'returns the issue that will be closed on merge' do
|
||||||
issue = create(:issue, project: project)
|
issue = create(:issue, project: project)
|
||||||
|
|
Loading…
Reference in a new issue