Commit 43d11880 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix-api-mr-notes-ordering' into 'master'

Return comments in created order in merge request API

Closes #1832

See merge request !985
parents 4fae34d6 6c9f527b
...@@ -29,6 +29,8 @@ v 7.13.1 ...@@ -29,6 +29,8 @@ v 7.13.1
v 7.13.0 v 7.13.0
- Remove repository graph log to fix slow cache updates after push event (Stan Hu) - Remove repository graph log to fix slow cache updates after push event (Stan Hu)
v 7.13.0 (unreleased)
- Return comments in created order in merge request API (Stan Hu)
- Only enable HSTS header for HTTPS and port 443 (Stan Hu) - Only enable HSTS header for HTTPS and port 443 (Stan Hu)
- Fix user autocomplete for unauthenticated users accessing public projects (Stan Hu) - Fix user autocomplete for unauthenticated users accessing public projects (Stan Hu)
- Fix redirection to home page URL for unauthorized users (Daniel Gerhardt) - Fix redirection to home page URL for unauthorized users (Daniel Gerhardt)
......
...@@ -229,7 +229,7 @@ module API ...@@ -229,7 +229,7 @@ module API
authorize! :read_merge_request, merge_request authorize! :read_merge_request, merge_request
present paginate(merge_request.notes), with: Entities::MRNote present paginate(merge_request.notes.fresh), with: Entities::MRNote
end end
# Post comment to merge request # Post comment to merge request
......
...@@ -8,6 +8,7 @@ describe API::API, api: true do ...@@ -8,6 +8,7 @@ describe API::API, api: true do
let!(:merge_request_closed) { create(:merge_request, state: "closed", author: user, assignee: user, source_project: project, target_project: project, title: "Closed test") } let!(:merge_request_closed) { create(:merge_request, state: "closed", author: user, assignee: user, source_project: project, target_project: project, title: "Closed test") }
let!(:merge_request_merged) { create(:merge_request, state: "merged", author: user, assignee: user, source_project: project, target_project: project, title: "Merged test") } let!(:merge_request_merged) { create(:merge_request, state: "merged", author: user, assignee: user, source_project: project, target_project: project, title: "Merged test") }
let!(:note) { create(:note_on_merge_request, author: user, project: project, noteable: merge_request, note: "a comment on a MR") } 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") }
before do before do
project.team << [user, :reporters] project.team << [user, :reporters]
...@@ -397,13 +398,14 @@ describe API::API, api: true do ...@@ -397,13 +398,14 @@ describe API::API, api: true do
end end
describe "GET :id/merge_request/:merge_request_id/comments" do describe "GET :id/merge_request/:merge_request_id/comments" do
it "should return merge_request comments" do it "should return merge_request comments ordered by created_at" do
get api("/projects/#{project.id}/merge_request/#{merge_request.id}/comments", user) get api("/projects/#{project.id}/merge_request/#{merge_request.id}/comments", user)
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(2)
expect(json_response.first['note']).to eq("a comment on a MR") 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.first['author']['id']).to eq(user.id)
expect(json_response.last['note']).to eq("another comment on a MR")
end end
it "should return a 404 error if merge_request_id not found" do it "should return a 404 error if merge_request_id not found" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment