Commit 662a3ff3 authored by Nick Thomas's avatar Nick Thomas Committed by Mayra Cabrera

Remove some unused code from the VisibleApprovable concern

parent a8bab018
......@@ -22,21 +22,11 @@ module VisibleApprovable
approvers
end
def all_approvers_including_groups
approval_state.approvers
end
def approvers_from_groups
groups = approval_state.wrapped_approval_rules.flat_map(&:groups)
User.joins(:group_members).where(members: { source_id: groups })
end
def reset_approval_cache!
approvals.reset
approved_by_users.reset
approval_rules.reset
clear_memoization(:all_approvers_including_groups)
clear_memoization(:approval_state)
end
end
......@@ -548,29 +548,6 @@ describe MergeRequest do
end
end
describe '#all_approvers_including_groups' do
it 'returns correct set of users' do
user = create :user
user1 = create :user
user2 = create :user
create :user
project = create :project
group = create :group
group.add_maintainer user
create :approver_group, target: project, group: group
merge_request = create :merge_request, target_project: project, source_project: project
group1 = create :group
group1.add_maintainer user1
create :approver_group, target: merge_request, group: group1
create(:approver, user: user2, target: merge_request)
expect(merge_request.all_approvers_including_groups).to match_array([user1, user2])
end
end
describe '#approver_group_ids=' do
it 'create approver_groups' do
group = create :group
......
......@@ -74,18 +74,6 @@ describe VisibleApprovable do
end
end
describe '#all_approvers_including_groups' do
let!(:group) { create(:group_with_members) }
let!(:approver) { create(:user) }
let!(:rule) { create(:approval_project_rule, project: project, groups: [group], users: [approver]) }
subject { resource.all_approvers_including_groups }
it 'returns all approvers (groups and users)' do
is_expected.to match_array(group.users + [approver])
end
end
describe '#authors_can_approve?' do
subject { resource.authors_can_approve? }
......@@ -99,22 +87,4 @@ describe VisibleApprovable do
is_expected.to be true
end
end
describe '#reset_approval_cache!' do
before do
approver = create(:user)
project.add_developer(approver)
create(:approval_project_rule, project: project, users: [approver])
end
subject { resource.reset_approval_cache! }
it 'clears the all_approvers_including_groups cache' do
resource.all_approvers_including_groups.first.destroy!
subject
expect(resource.all_approvers_including_groups).to be_empty
end
end
end
......@@ -83,25 +83,6 @@ describe MergeRequestPresenter do
it { is_expected.to eq(expose_path("/api/v4/projects/#{merge_request.project.id}/merge_requests/#{merge_request.iid}/unapprove")) }
end
describe '#all_approvers_including_groups with approval_rule enabled' do
let!(:private_group) { create(:group_with_members, :private) }
let!(:public_group) { create(:group_with_members) }
let!(:approver) { create(:user) }
let!(:approval_rule) { create(:approval_merge_request_rule, merge_request: merge_request, users: [approver], groups: [private_group, public_group]) }
before do
project.add_developer(approver)
end
subject { described_class.new(merge_request, current_user: user).all_approvers_including_groups }
it do
approvers = [public_group.users, private_group.users, approver].flatten - [user]
is_expected.to match_array(approvers)
end
end
describe '#suggested_approvers' do
subject { described_class.new(merge_request, current_user: user).suggested_approvers }
......
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