Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2b40c12c
Commit
2b40c12c
authored
Jan 14, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compatibility switch for approval related methods
Only call ApprovalState when enabled
parent
a94094a6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
0 deletions
+74
-0
ee/app/models/concerns/approvable_for_rule.rb
ee/app/models/concerns/approvable_for_rule.rb
+29
-0
ee/app/models/concerns/visible_approvable_for_rule.rb
ee/app/models/concerns/visible_approvable_for_rule.rb
+35
-0
ee/app/models/ee/merge_request.rb
ee/app/models/ee/merge_request.rb
+1
-0
ee/app/presenters/ee/merge_request_presenter.rb
ee/app/presenters/ee/merge_request_presenter.rb
+1
-0
ee/spec/models/approvable_spec.rb
ee/spec/models/approvable_spec.rb
+4
-0
ee/spec/models/visible_approvable_spec.rb
ee/spec/models/visible_approvable_spec.rb
+4
-0
No files found.
ee/app/models/concerns/approvable_for_rule.rb
0 → 100644
View file @
2b40c12c
# frozen_string_literal: true
module
ApprovableForRule
include
VisibleApprovableForRule
FORWARDABLE_METHODS
=
%w{
approval_needed?
approved?
approvals_left
can_approve?
has_approved?
any_approver_allowed?
authors_can_approve?
}
.
freeze
FORWARDABLE_METHODS
.
each
do
|
method
|
define_method
(
method
)
do
|*
args
|
return
super
(
*
args
)
if
::
Feature
.
disabled?
(
:approval_rule
)
approval_state
.
public_send
(
method
,
*
args
)
# rubocop:disable GitlabSecurity/PublicSend
end
end
def
approvers_overwritten?
return
super
if
::
Feature
.
disabled?
(
:approval_rule
)
approval_state
.
approval_rules_overwritten?
end
end
ee/app/models/concerns/visible_approvable_for_rule.rb
0 → 100644
View file @
2b40c12c
# frozen_string_literal: true
# This module may only be used by presenters or modules
# that include the Approvable concern
module
VisibleApprovableForRule
def
approvers_left
return
super
if
::
Feature
.
disabled?
(
:approval_rule
)
approval_state
.
unactioned_approvers
end
def
overall_approvers
(
exclude_code_owners:
false
)
return
super
if
::
Feature
.
disabled?
(
:approval_rule
)
options
=
{
target: :users
}
options
[
:code_owner
]
=
false
if
exclude_code_owners
approvers
=
approval_state
.
filtered_approvers
(
options
)
approvers
.
uniq!
approvers
end
def
all_approvers_including_groups
return
super
if
::
Feature
.
disabled?
(
:approval_rule
)
approval_state
.
approvers
end
def
approvers_from_groups
return
super
if
::
Feature
.
disabled?
(
:approval_rule
)
groups
=
approval_state
.
wrapped_approval_rules
.
flat_map
(
&
:groups
)
User
.
joins
(
:group_members
).
where
(
members:
{
source_id:
groups
})
end
end
ee/app/models/ee/merge_request.rb
View file @
2b40c12c
...
...
@@ -7,6 +7,7 @@ module EE
include
::
Approvable
include
::
Gitlab
::
Utils
::
StrongMemoize
prepend
ApprovableForRule
prepended
do
include
Elastic
::
MergeRequestsSearch
...
...
ee/app/presenters/ee/merge_request_presenter.rb
View file @
2b40c12c
...
...
@@ -3,6 +3,7 @@
module
EE
module
MergeRequestPresenter
include
::
VisibleApprovable
prepend
VisibleApprovableForRule
def
approvals_path
if
requires_approve?
...
...
ee/spec/models/approvable_spec.rb
View file @
2b40c12c
...
...
@@ -5,6 +5,10 @@ describe Approvable do
let
(
:project
)
{
merge_request
.
project
}
let
(
:author
)
{
merge_request
.
author
}
before
do
stub_feature_flags
(
approval_rule:
false
)
end
describe
'#approvers_overwritten?'
do
subject
{
merge_request
.
approvers_overwritten?
}
...
...
ee/spec/models/visible_approvable_spec.rb
View file @
2b40c12c
...
...
@@ -5,6 +5,10 @@ describe VisibleApprovable do
let!
(
:project
)
{
create
(
:project
,
:repository
)
}
let!
(
:user
)
{
project
.
creator
}
before
do
stub_feature_flags
(
approval_rule:
false
)
end
describe
'#requires_approve'
do
subject
{
resource
.
requires_approve?
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment