Commit 2c35acfe authored by Robert Speicher's avatar Robert Speicher

Merge branch '6670-extract-ee-specific-files-lines-for-discussion-spec-requests-api' into 'master'

Extract EE specific files/lines for Discussion spec/requests/api

Closes #6670

See merge request gitlab-org/gitlab-ee!10603
parents b954c248 933723f8
# frozen_string_literal: true
require 'spec_helper'
describe API::Discussions do
let(:user) { create(:user) }
let!(:project) { create(:project, :public, :repository, namespace: user.namespace) }
let(:private_user) { create(:user) }
before do
project.add_developer(user)
end
context 'when noteable is an Epic' do
let(:group) { create(:group, :public) }
let(:epic) { create(:epic, group: group, author: user) }
let!(:epic_note) { create(:discussion_note, noteable: epic, project: project, author: user) }
before do
group.add_owner(user)
stub_licensed_features(epics: true)
end
it_behaves_like 'discussions API', 'groups', 'epics', 'id' do
let(:parent) { group }
let(:noteable) { epic }
let(:note) { epic_note }
end
end
end
......@@ -170,6 +170,29 @@ describe API::MergeRequests do
end
end
describe "PUT /projects/:id/merge_requests/:merge_request_iid/merge" do
it 'returns 405 if merge request was not approved' do
project.add_developer(create(:user))
project.update(approvals_before_merge: 1)
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
expect(response).to have_gitlab_http_status(406)
expect(json_response['message']).to eq('Branch cannot be merged')
end
it 'returns 200 if merge request was approved' do
approver = create(:user)
project.add_developer(approver)
project.update(approvals_before_merge: 1)
merge_request.approvals.create(user: approver)
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
expect(response).to have_gitlab_http_status(200)
end
end
context 'when authenticated' do
def expect_response_contain_exactly(*items)
expect(response).to have_gitlab_http_status(200)
......
# frozen_string_literal: true
require 'spec_helper'
describe API::Notes do
let(:user) { create(:user) }
let!(:project) { create(:project, :public, namespace: user.namespace) }
let(:private_user) { create(:user) }
before do
project.add_reporter(user)
end
context "when noteable is an Epic" do
let(:group) { create(:group, :public) }
let(:epic) { create(:epic, group: group, author: user) }
let!(:epic_note) { create(:note, noteable: epic, project: project, author: user) }
before do
group.add_owner(user)
stub_licensed_features(epics: true)
end
it_behaves_like "noteable API", 'groups', 'epics', 'id' do
let(:parent) { group }
let(:noteable) { epic }
let(:note) { epic_note }
end
end
end
......@@ -31,24 +31,6 @@ describe API::Discussions do
end
end
context 'when noteable is an Epic' do
let(:group) { create(:group, :public) }
let(:ext_group) { create(:group, :public) }
let(:epic) { create(:epic, group: group, author: user) }
let!(:epic_note) { create(:discussion_note, noteable: epic, project: project, author: user) }
before do
group.add_owner(user)
stub_licensed_features(epics: true)
end
it_behaves_like 'discussions API', 'groups', 'epics', 'id' do
let(:parent) { group }
let(:noteable) { epic }
let(:note) { epic_note }
end
end
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) }
......
......@@ -1443,27 +1443,6 @@ describe API::MergeRequests do
expect(json_response['message']).to eq('405 Method Not Allowed')
end
it 'returns 405 if merge request was not approved' do
project.add_developer(create(:user))
project.update(approvals_before_merge: 1)
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
expect(response).to have_gitlab_http_status(406)
expect(json_response['message']).to eq('Branch cannot be merged')
end
it 'returns 200 if merge request was approved' do
approver = create(:user)
project.add_developer(approver)
project.update(approvals_before_merge: 1)
merge_request.approvals.create(user: approver)
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
expect(response).to have_gitlab_http_status(200)
end
it "returns 401 if user has no permissions to merge" do
user2 = create(:user)
project.add_reporter(user2)
......
......@@ -182,22 +182,4 @@ describe API::Notes do
end
end
end
context "when noteable is an Epic" do
let(:group) { create(:group, :public) }
let(:ext_group) { create(:group, :public) }
let(:epic) { create(:epic, group: group, author: user) }
let!(:epic_note) { create(:note, noteable: epic, project: project, author: user) }
before do
group.add_owner(user)
stub_licensed_features(epics: true)
end
it_behaves_like "noteable API", 'groups', 'epics', 'id' do
let(:parent) { group }
let(:noteable) { epic }
let(:note) { epic_note }
end
end
end
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