2018-02-28 07:48:23 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe API::Discussions do
|
|
|
|
let(:user) { create(:user) }
|
2018-05-01 12:39:44 +00:00
|
|
|
let!(:project) { create(:project, :public, :repository, namespace: user.namespace) }
|
2019-01-16 12:09:29 +00:00
|
|
|
let(:private_user) { create(:user) }
|
2018-02-28 07:48:23 +00:00
|
|
|
|
|
|
|
before do
|
2018-05-01 12:39:44 +00:00
|
|
|
project.add_developer(user)
|
2018-02-28 07:48:23 +00:00
|
|
|
end
|
|
|
|
|
2019-08-22 07:19:44 +00:00
|
|
|
context 'when discussions have cross-reference system notes' do
|
2019-08-15 04:50:52 +00:00
|
|
|
let(:url) { "/projects/#{project.id}/merge_requests/#{merge_request.iid}/discussions" }
|
2019-08-22 07:19:44 +00:00
|
|
|
let(:notes_in_response) { json_response.first['notes'] }
|
2019-08-15 04:50:52 +00:00
|
|
|
|
2019-08-22 07:19:44 +00:00
|
|
|
it_behaves_like 'with cross-reference system notes'
|
2019-08-15 04:50:52 +00:00
|
|
|
end
|
|
|
|
|
2018-05-01 12:39:44 +00:00
|
|
|
context 'when noteable is an Issue' do
|
2018-02-28 07:48:23 +00:00
|
|
|
let!(:issue) { create(:issue, project: project, author: user) }
|
|
|
|
let!(:issue_note) { create(:discussion_note_on_issue, noteable: issue, project: project, author: user) }
|
|
|
|
|
2019-05-20 14:11:44 +00:00
|
|
|
it_behaves_like 'discussions API', 'projects', 'issues', 'iid', can_reply_to_individual_notes: true do
|
2018-02-28 07:48:23 +00:00
|
|
|
let(:parent) { project }
|
|
|
|
let(:noteable) { issue }
|
|
|
|
let(:note) { issue_note }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-01 12:39:44 +00:00
|
|
|
context 'when noteable is a Snippet' do
|
2018-02-28 07:48:23 +00:00
|
|
|
let!(:snippet) { create(:project_snippet, project: project, author: user) }
|
|
|
|
let!(:snippet_note) { create(:discussion_note_on_snippet, noteable: snippet, project: project, author: user) }
|
|
|
|
|
2018-05-01 12:39:44 +00:00
|
|
|
it_behaves_like 'discussions API', 'projects', 'snippets', 'id' do
|
2018-02-28 07:48:23 +00:00
|
|
|
let(:parent) { project }
|
|
|
|
let(:noteable) { snippet }
|
|
|
|
let(:note) { snippet_note }
|
|
|
|
end
|
|
|
|
end
|
2018-05-01 12:39:44 +00:00
|
|
|
|
|
|
|
context 'when noteable is a Merge Request' do
|
|
|
|
let!(:noteable) { create(:merge_request_with_diffs, source_project: project, target_project: project, author: user) }
|
|
|
|
let!(:note) { create(:discussion_note_on_merge_request, noteable: noteable, project: project, author: user) }
|
|
|
|
let!(:diff_note) { create(:diff_note_on_merge_request, noteable: noteable, project: project, author: user) }
|
|
|
|
let(:parent) { project }
|
|
|
|
|
2019-05-20 14:11:44 +00:00
|
|
|
it_behaves_like 'discussions API', 'projects', 'merge_requests', 'iid', can_reply_to_individual_notes: true
|
2018-05-01 12:39:44 +00:00
|
|
|
it_behaves_like 'diff discussions API', 'projects', 'merge_requests', 'iid'
|
|
|
|
it_behaves_like 'resolvable discussions API', 'projects', 'merge_requests', 'iid'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when noteable is a Commit' do
|
|
|
|
let!(:noteable) { create(:commit, project: project, author: user) }
|
|
|
|
let!(:note) { create(:discussion_note_on_commit, commit_id: noteable.id, project: project, author: user) }
|
|
|
|
let!(:diff_note) { create(:diff_note_on_commit, commit_id: noteable.id, project: project, author: user) }
|
|
|
|
let(:parent) { project }
|
|
|
|
|
|
|
|
it_behaves_like 'discussions API', 'projects', 'repository/commits', 'id'
|
|
|
|
it_behaves_like 'diff discussions API', 'projects', 'repository/commits', 'id'
|
|
|
|
end
|
2018-02-28 07:48:23 +00:00
|
|
|
end
|