Commit 933723f8 authored by Brett Walker's avatar Brett Walker

Extracted EE changes

- discussions_spec.rb
- merge_requests_spec.rb
- notes_spec.rb
parent dcba84ce
# 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
......@@ -204,6 +204,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