Commit 3b9d4255 authored by Mark Chao's avatar Mark Chao

Dry feature check into a method

parent 34c5a8db
......@@ -16,7 +16,7 @@ module ApprovableForRule
FORWARDABLE_METHODS.each do |method|
define_method(method) do |*args|
return super(*args) if ::Feature.disabled?(:approval_rules, project)
return super(*args) if approval_rules_disabled?
approval_state.public_send(method, *args) # rubocop:disable GitlabSecurity/PublicSend
end
......
......@@ -4,13 +4,13 @@
# that include the Approvable concern
module VisibleApprovableForRule
def approvers_left
return super if ::Feature.disabled?(:approval_rules, project)
return super if approval_rules_disabled?
approval_state.unactioned_approvers
end
def overall_approvers(exclude_code_owners: false)
return super if ::Feature.disabled?(:approval_rules, project)
return super if approval_rules_disabled?
options = { target: :users }
options[:code_owner] = false if exclude_code_owners
......@@ -21,15 +21,19 @@ module VisibleApprovableForRule
end
def all_approvers_including_groups
return super if ::Feature.disabled?(:approval_rules, project)
return super if approval_rules_disabled?
approval_state.approvers
end
def approvers_from_groups
return super if ::Feature.disabled?(:approval_rules, project)
return super if approval_rules_disabled?
groups = approval_state.wrapped_approval_rules.flat_map(&:groups)
User.joins(:group_members).where(members: { source_id: groups })
end
def approval_rules_disabled?
::Feature.disabled?(:approval_rules, project)
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