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
8b34de94
Commit
8b34de94
authored
Jan 15, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ApprovalRulePresenter for private group filter
Similar to MergeRequestPresenter
parent
da7574dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
ee/app/presenters/approval_rule_presenter.rb
ee/app/presenters/approval_rule_presenter.rb
+7
-0
ee/spec/presenters/approval_rule_presenter_spec.rb
ee/spec/presenters/approval_rule_presenter_spec.rb
+45
-0
No files found.
ee/app/presenters/approval_rule_presenter.rb
0 → 100644
View file @
8b34de94
# frozen_string_literal: true
class
ApprovalRulePresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
def
groups
super
.
public_or_visible_to_user
(
current_user
)
end
end
ee/spec/presenters/approval_rule_presenter_spec.rb
0 → 100644
View file @
8b34de94
# frozen_string_literal: true
require
'spec_helper'
describe
ApprovalRulePresenter
do
describe
'#groups'
do
set
(
:user
)
{
create
(
:user
)
}
set
(
:public_group
)
{
create
(
:group
)
}
set
(
:private_group
)
{
create
(
:group
,
:private
)
}
let
(
:groups
)
{
[
public_group
,
private_group
]
}
shared_examples
'filtering private group'
do
subject
{
described_class
.
new
(
rule
,
current_user:
user
)
}
context
'when user has no access to private group'
do
it
'excludes private group'
do
expect
(
subject
.
groups
).
to
contain_exactly
(
public_group
)
end
end
context
'when user has access to private group'
do
it
'includes private group'
do
private_group
.
add_owner
(
user
)
expect
(
subject
.
groups
).
to
contain_exactly
(
*
groups
)
end
end
end
context
'project rule'
do
let
(
:rule
)
{
create
(
:approval_project_rule
,
groups:
groups
)
}
it_behaves_like
'filtering private group'
end
context
'wrapped approval rule'
do
let
(
:rule
)
do
mr_rule
=
create
(
:approval_merge_request_rule
,
groups:
groups
)
ApprovalWrappedRule
.
new
(
mr_rule
.
merge_request
,
mr_rule
)
end
it_behaves_like
'filtering private group'
end
end
end
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