Commit baba96bc authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-approval-spec-one-member' into 'master'

Fix approval spec for project with only one member

See merge request !2117
parents 353edd07 0fde217b
...@@ -1510,17 +1510,18 @@ describe MergeRequest, models: true do ...@@ -1510,17 +1510,18 @@ describe MergeRequest, models: true do
let(:approver) { create(:user) } let(:approver) { create(:user) }
context 'on a project with only one member' do context 'on a project with only one member' do
let(:author) { project.owner }
context 'when there is one approver' do context 'when there is one approver' do
before { project.update_attributes(approvals_before_merge: 1) } before { project.update_attributes(approvals_before_merge: 1) }
context 'when that approver is the MR author' do context 'when that approver is the MR author' do
before do before do
project.team << [author, :developer]
create(:approver, user: author, target: merge_request) create(:approver, user: author, target: merge_request)
end end
it 'does not require approval for the merge request' do it 'does not require approval for the merge request' do
expect(merge_request.approvals_left).to eq(1) expect(merge_request.approvals_left).to eq(0)
end end
it 'does not allow the approver to approve the MR' do it 'does not allow the approver to approve the MR' do
...@@ -1531,25 +1532,6 @@ describe MergeRequest, models: true do ...@@ -1531,25 +1532,6 @@ describe MergeRequest, models: true do
expect(merge_request.can_approve?(nil)).to be_falsey expect(merge_request.can_approve?(nil)).to be_falsey
end end
end end
context 'when that approver is not the MR author' do
before do
project.team << [approver, :developer]
create(:approver, user: approver, target: merge_request)
end
it 'requires one approval' do
expect(merge_request.approvals_left).to eq(1)
end
it 'allows the approver to approve the MR' do
expect(merge_request.can_approve?(approver)).to be_truthy
end
it 'does not allow a logged-out user to approve the MR' do
expect(merge_request.can_approve?(nil)).to be_falsey
end
end
end 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