Commit 9654fdb3 authored by James Lopez's avatar James Lopez

Merge branch '9076-spec' into 'master'

Remove unused add_member/delete_member

Closes #9076

See merge request gitlab-org/gitlab-ee!15013
parents 7aee7a9e 8fb35197
......@@ -28,24 +28,6 @@ module ApprovalRuleLike
end
end
def add_member(member)
case member
when User
users << member unless users.exists?(member.id)
when Group
groups << member unless groups.exists?(member.id)
end
end
def remove_member(member)
case member
when User
users.delete(member)
when Group
groups.delete(member)
end
end
def code_owner?
raise NotImplementedError
end
......
......@@ -22,7 +22,12 @@ describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRules do
end
if populate_in.include?(:new_schema)
approval_rule.add_member(member)
case member
when User
approval_rule.users << member
when Group
approval_rule.groups << member
end
end
end
......
......@@ -12,39 +12,6 @@ describe ApprovalRuleLike do
let(:merge_request) { create(:merge_request) }
shared_examples 'approval rule like' do
describe '#add_member' do
it 'adds as a member of the rule' do
expect do
subject.add_member(user1)
subject.add_member(group1)
end.to change { subject.users.count }.by(1).and change { subject.groups.count }.by(1)
end
it 'does nothing if already a member' do
subject.add_member(user1)
expect do
subject.add_member(user1)
end.not_to change { subject.users.count + subject.groups.count }
end
end
describe '#remove_member' do
it 'removes a member from the rule' do
subject.add_member(group1)
expect do
subject.remove_member(group1)
end.to change { subject.groups.count }.by(-1)
end
it 'does nothing if not a member' do
expect do
subject.remove_member(group1)
end.not_to change { subject.groups.count }
end
end
describe '#approvers' do
let(:group1_user) { create(:user) }
let(:group2_user) { create(:user) }
......
......@@ -38,7 +38,12 @@ describe ApproverMigrateHook do
context 'when member mapping already exists' do
before do
approval_rule.add_member approver.member
case member
when User
approval_rule.users << member
when Group
approval_rule.groups << member
end
end
it 'does nothing' do
......@@ -64,7 +69,8 @@ describe ApproverMigrateHook do
end
context 'User' do
let(:approver) { create(:approver, target: target) }
let(:member) { create(:user) }
let(:approver) { create(:approver, target: target, user: member) }
context 'merge request' do
let(:target) { create(:merge_request) }
......@@ -80,7 +86,8 @@ describe ApproverMigrateHook do
end
context 'Group' do
let(:approver) { create(:approver_group, target: target) }
let(:member) { create(:group) }
let(:approver) { create(:approver_group, target: target, group: member) }
context 'merge request' do
let(:target) { create(:merge_request) }
......
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