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
01cfcc8d
Commit
01cfcc8d
authored
Feb 06, 2020
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract snippet related permission table
For reuse in other areas
parent
d9613bc7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
169 additions
and
156 deletions
+169
-156
ee/spec/services/search/snippet_service_spec.rb
ee/spec/services/search/snippet_service_spec.rb
+5
-156
spec/support/shared_contexts/policies/project_policy_table_shared_context.rb
..._contexts/policies/project_policy_table_shared_context.rb
+164
-0
No files found.
ee/spec/services/search/snippet_service_spec.rb
View file @
01cfcc8d
...
@@ -21,6 +21,9 @@ describe Search::SnippetService do
...
@@ -21,6 +21,9 @@ describe Search::SnippetService do
end
end
context
'visibility'
do
context
'visibility'
do
include_context
'ProjectPolicyTable context'
include
ProjectHelpers
let
(
:search_term
)
{
'foobar'
}
let
(
:search_term
)
{
'foobar'
}
context
'project snippet'
do
context
'project snippet'
do
...
@@ -50,148 +53,7 @@ describe Search::SnippetService do
...
@@ -50,148 +53,7 @@ describe Search::SnippetService do
let
(
:user
)
{
create_user_from_membership
(
project
,
membership
)
}
let
(
:user
)
{
create_user_from_membership
(
project
,
membership
)
}
where
(
:snippet_level
,
:project_level
,
:feature_access_level
,
:membership
,
:expected_count
)
do
where
(
:snippet_level
,
:project_level
,
:feature_access_level
,
:membership
,
:expected_count
)
do
:public
|
:public
|
:enabled
|
:admin
|
1
permission_table_for_project_snippet_access
:public
|
:public
|
:enabled
|
:reporter
|
1
:public
|
:public
|
:enabled
|
:guest
|
1
:public
|
:public
|
:enabled
|
:non_member
|
1
:public
|
:public
|
:enabled
|
:anonymous
|
1
:public
|
:public
|
:private
|
:admin
|
1
:public
|
:public
|
:private
|
:reporter
|
1
:public
|
:public
|
:private
|
:guest
|
1
:public
|
:public
|
:private
|
:non_member
|
0
:public
|
:public
|
:private
|
:anonymous
|
0
:public
|
:public
|
:disabled
|
:admin
|
1
:public
|
:public
|
:disabled
|
:reporter
|
0
:public
|
:public
|
:disabled
|
:guest
|
0
:public
|
:public
|
:disabled
|
:non_member
|
0
:public
|
:public
|
:disabled
|
:anonymous
|
0
:public
|
:internal
|
:enabled
|
:admin
|
1
:public
|
:internal
|
:enabled
|
:reporter
|
1
:public
|
:internal
|
:enabled
|
:guest
|
1
:public
|
:internal
|
:enabled
|
:non_member
|
1
:public
|
:internal
|
:enabled
|
:anonymous
|
0
:public
|
:internal
|
:private
|
:admin
|
1
:public
|
:internal
|
:private
|
:reporter
|
1
:public
|
:internal
|
:private
|
:guest
|
1
:public
|
:internal
|
:private
|
:non_member
|
0
:public
|
:internal
|
:private
|
:anonymous
|
0
:public
|
:internal
|
:disabled
|
:admin
|
1
:public
|
:internal
|
:disabled
|
:reporter
|
0
:public
|
:internal
|
:disabled
|
:guest
|
0
:public
|
:internal
|
:disabled
|
:non_member
|
0
:public
|
:internal
|
:disabled
|
:anonymous
|
0
:public
|
:private
|
:private
|
:admin
|
1
:public
|
:private
|
:private
|
:reporter
|
1
:public
|
:private
|
:private
|
:guest
|
1
:public
|
:private
|
:private
|
:non_member
|
0
:public
|
:private
|
:private
|
:anonymous
|
0
:public
|
:private
|
:disabled
|
:reporter
|
0
:public
|
:private
|
:disabled
|
:guest
|
0
:public
|
:private
|
:disabled
|
:non_member
|
0
:public
|
:private
|
:disabled
|
:anonymous
|
0
:internal
|
:public
|
:enabled
|
:admin
|
1
:internal
|
:public
|
:enabled
|
:reporter
|
1
:internal
|
:public
|
:enabled
|
:guest
|
1
:internal
|
:public
|
:enabled
|
:non_member
|
1
:internal
|
:public
|
:enabled
|
:anonymous
|
0
:internal
|
:public
|
:private
|
:admin
|
1
:internal
|
:public
|
:private
|
:reporter
|
1
:internal
|
:public
|
:private
|
:guest
|
1
:internal
|
:public
|
:private
|
:non_member
|
0
:internal
|
:public
|
:private
|
:anonymous
|
0
:internal
|
:public
|
:disabled
|
:admin
|
1
:internal
|
:public
|
:disabled
|
:reporter
|
0
:internal
|
:public
|
:disabled
|
:guest
|
0
:internal
|
:public
|
:disabled
|
:non_member
|
0
:internal
|
:public
|
:disabled
|
:anonymous
|
0
:internal
|
:internal
|
:enabled
|
:admin
|
1
:internal
|
:internal
|
:enabled
|
:reporter
|
1
:internal
|
:internal
|
:enabled
|
:guest
|
1
:internal
|
:internal
|
:enabled
|
:non_member
|
1
:internal
|
:internal
|
:enabled
|
:anonymous
|
0
:internal
|
:internal
|
:private
|
:admin
|
1
:internal
|
:internal
|
:private
|
:reporter
|
1
:internal
|
:internal
|
:private
|
:guest
|
1
:internal
|
:internal
|
:private
|
:non_member
|
0
:internal
|
:internal
|
:private
|
:anonymous
|
0
:internal
|
:internal
|
:disabled
|
:admin
|
1
:internal
|
:internal
|
:disabled
|
:reporter
|
0
:internal
|
:internal
|
:disabled
|
:guest
|
0
:internal
|
:internal
|
:disabled
|
:non_member
|
0
:internal
|
:internal
|
:disabled
|
:anonymous
|
0
:internal
|
:private
|
:private
|
:admin
|
1
:internal
|
:private
|
:private
|
:reporter
|
1
:internal
|
:private
|
:private
|
:guest
|
1
:internal
|
:private
|
:private
|
:non_member
|
0
:internal
|
:private
|
:private
|
:anonymous
|
0
:internal
|
:private
|
:disabled
|
:admin
|
1
:internal
|
:private
|
:disabled
|
:reporter
|
0
:internal
|
:private
|
:disabled
|
:guest
|
0
:internal
|
:private
|
:disabled
|
:non_member
|
0
:internal
|
:private
|
:disabled
|
:anonymous
|
0
:private
|
:public
|
:enabled
|
:admin
|
1
:private
|
:public
|
:enabled
|
:reporter
|
1
:private
|
:public
|
:enabled
|
:guest
|
1
:private
|
:public
|
:enabled
|
:non_member
|
0
:private
|
:public
|
:enabled
|
:anonymous
|
0
:private
|
:public
|
:private
|
:admin
|
1
:private
|
:public
|
:private
|
:reporter
|
1
:private
|
:public
|
:private
|
:guest
|
1
:private
|
:public
|
:private
|
:non_member
|
0
:private
|
:public
|
:private
|
:anonymous
|
0
:private
|
:public
|
:disabled
|
:admin
|
1
:private
|
:public
|
:disabled
|
:reporter
|
0
:private
|
:public
|
:disabled
|
:guest
|
0
:private
|
:public
|
:disabled
|
:non_member
|
0
:private
|
:public
|
:disabled
|
:anonymous
|
0
:private
|
:internal
|
:enabled
|
:admin
|
1
:private
|
:internal
|
:enabled
|
:reporter
|
1
:private
|
:internal
|
:enabled
|
:guest
|
1
:private
|
:internal
|
:enabled
|
:non_member
|
0
:private
|
:internal
|
:enabled
|
:anonymous
|
0
:private
|
:internal
|
:private
|
:admin
|
1
:private
|
:internal
|
:private
|
:reporter
|
1
:private
|
:internal
|
:private
|
:guest
|
1
:private
|
:internal
|
:private
|
:non_member
|
0
:private
|
:internal
|
:private
|
:anonymous
|
0
:private
|
:internal
|
:disabled
|
:admin
|
1
:private
|
:internal
|
:disabled
|
:reporter
|
0
:private
|
:internal
|
:disabled
|
:guest
|
0
:private
|
:internal
|
:disabled
|
:non_member
|
0
:private
|
:internal
|
:disabled
|
:anonymous
|
0
:private
|
:private
|
:private
|
:admin
|
1
:private
|
:private
|
:private
|
:reporter
|
1
:private
|
:private
|
:private
|
:guest
|
1
:private
|
:private
|
:private
|
:non_member
|
0
:private
|
:private
|
:private
|
:anonymous
|
0
:private
|
:private
|
:disabled
|
:admin
|
1
:private
|
:private
|
:disabled
|
:reporter
|
0
:private
|
:private
|
:disabled
|
:guest
|
0
:private
|
:private
|
:disabled
|
:non_member
|
0
:private
|
:private
|
:disabled
|
:anonymous
|
0
end
end
with_them
do
with_them
do
...
@@ -223,20 +85,7 @@ describe Search::SnippetService do
...
@@ -223,20 +85,7 @@ describe Search::SnippetService do
let!
(
:snippet
)
{
create
(
:personal_snippet
,
snippet_level
,
title:
search_term
,
content:
search_term
)
}
let!
(
:snippet
)
{
create
(
:personal_snippet
,
snippet_level
,
title:
search_term
,
content:
search_term
)
}
where
(
:snippet_level
,
:membership
,
:expected_count
)
do
where
(
:snippet_level
,
:membership
,
:expected_count
)
do
:public
|
:admin
|
1
permission_table_for_personal_snippet_access
:public
|
:author
|
1
:public
|
:non_member
|
1
:public
|
:anonymous
|
1
:internal
|
:admin
|
1
:internal
|
:author
|
1
:internal
|
:non_member
|
1
:internal
|
:anonymous
|
0
:private
|
:admin
|
1
:private
|
:author
|
1
:private
|
:non_member
|
0
:private
|
:anonymous
|
0
end
end
with_them
do
with_them
do
...
...
spec/support/shared_contexts/policies/project_policy_table_shared_context.rb
View file @
01cfcc8d
...
@@ -318,5 +318,169 @@ RSpec.shared_context 'ProjectPolicyTable context' do
...
@@ -318,5 +318,169 @@ RSpec.shared_context 'ProjectPolicyTable context' do
:private
|
:non_member
|
0
:private
|
:non_member
|
0
:private
|
:anonymous
|
0
:private
|
:anonymous
|
0
end
end
# :snippet_level, :project_level, :feature_access_level, :membership, :expected_count
def
permission_table_for_project_snippet_access
:public
|
:public
|
:enabled
|
:admin
|
1
:public
|
:public
|
:enabled
|
:reporter
|
1
:public
|
:public
|
:enabled
|
:guest
|
1
:public
|
:public
|
:enabled
|
:non_member
|
1
:public
|
:public
|
:enabled
|
:anonymous
|
1
:public
|
:public
|
:private
|
:admin
|
1
:public
|
:public
|
:private
|
:reporter
|
1
:public
|
:public
|
:private
|
:guest
|
1
:public
|
:public
|
:private
|
:non_member
|
0
:public
|
:public
|
:private
|
:anonymous
|
0
:public
|
:public
|
:disabled
|
:admin
|
1
:public
|
:public
|
:disabled
|
:reporter
|
0
:public
|
:public
|
:disabled
|
:guest
|
0
:public
|
:public
|
:disabled
|
:non_member
|
0
:public
|
:public
|
:disabled
|
:anonymous
|
0
:public
|
:internal
|
:enabled
|
:admin
|
1
:public
|
:internal
|
:enabled
|
:reporter
|
1
:public
|
:internal
|
:enabled
|
:guest
|
1
:public
|
:internal
|
:enabled
|
:non_member
|
1
:public
|
:internal
|
:enabled
|
:anonymous
|
0
:public
|
:internal
|
:private
|
:admin
|
1
:public
|
:internal
|
:private
|
:reporter
|
1
:public
|
:internal
|
:private
|
:guest
|
1
:public
|
:internal
|
:private
|
:non_member
|
0
:public
|
:internal
|
:private
|
:anonymous
|
0
:public
|
:internal
|
:disabled
|
:admin
|
1
:public
|
:internal
|
:disabled
|
:reporter
|
0
:public
|
:internal
|
:disabled
|
:guest
|
0
:public
|
:internal
|
:disabled
|
:non_member
|
0
:public
|
:internal
|
:disabled
|
:anonymous
|
0
:public
|
:private
|
:private
|
:admin
|
1
:public
|
:private
|
:private
|
:reporter
|
1
:public
|
:private
|
:private
|
:guest
|
1
:public
|
:private
|
:private
|
:non_member
|
0
:public
|
:private
|
:private
|
:anonymous
|
0
:public
|
:private
|
:disabled
|
:reporter
|
0
:public
|
:private
|
:disabled
|
:guest
|
0
:public
|
:private
|
:disabled
|
:non_member
|
0
:public
|
:private
|
:disabled
|
:anonymous
|
0
:internal
|
:public
|
:enabled
|
:admin
|
1
:internal
|
:public
|
:enabled
|
:reporter
|
1
:internal
|
:public
|
:enabled
|
:guest
|
1
:internal
|
:public
|
:enabled
|
:non_member
|
1
:internal
|
:public
|
:enabled
|
:anonymous
|
0
:internal
|
:public
|
:private
|
:admin
|
1
:internal
|
:public
|
:private
|
:reporter
|
1
:internal
|
:public
|
:private
|
:guest
|
1
:internal
|
:public
|
:private
|
:non_member
|
0
:internal
|
:public
|
:private
|
:anonymous
|
0
:internal
|
:public
|
:disabled
|
:admin
|
1
:internal
|
:public
|
:disabled
|
:reporter
|
0
:internal
|
:public
|
:disabled
|
:guest
|
0
:internal
|
:public
|
:disabled
|
:non_member
|
0
:internal
|
:public
|
:disabled
|
:anonymous
|
0
:internal
|
:internal
|
:enabled
|
:admin
|
1
:internal
|
:internal
|
:enabled
|
:reporter
|
1
:internal
|
:internal
|
:enabled
|
:guest
|
1
:internal
|
:internal
|
:enabled
|
:non_member
|
1
:internal
|
:internal
|
:enabled
|
:anonymous
|
0
:internal
|
:internal
|
:private
|
:admin
|
1
:internal
|
:internal
|
:private
|
:reporter
|
1
:internal
|
:internal
|
:private
|
:guest
|
1
:internal
|
:internal
|
:private
|
:non_member
|
0
:internal
|
:internal
|
:private
|
:anonymous
|
0
:internal
|
:internal
|
:disabled
|
:admin
|
1
:internal
|
:internal
|
:disabled
|
:reporter
|
0
:internal
|
:internal
|
:disabled
|
:guest
|
0
:internal
|
:internal
|
:disabled
|
:non_member
|
0
:internal
|
:internal
|
:disabled
|
:anonymous
|
0
:internal
|
:private
|
:private
|
:admin
|
1
:internal
|
:private
|
:private
|
:reporter
|
1
:internal
|
:private
|
:private
|
:guest
|
1
:internal
|
:private
|
:private
|
:non_member
|
0
:internal
|
:private
|
:private
|
:anonymous
|
0
:internal
|
:private
|
:disabled
|
:admin
|
1
:internal
|
:private
|
:disabled
|
:reporter
|
0
:internal
|
:private
|
:disabled
|
:guest
|
0
:internal
|
:private
|
:disabled
|
:non_member
|
0
:internal
|
:private
|
:disabled
|
:anonymous
|
0
:private
|
:public
|
:enabled
|
:admin
|
1
:private
|
:public
|
:enabled
|
:reporter
|
1
:private
|
:public
|
:enabled
|
:guest
|
1
:private
|
:public
|
:enabled
|
:non_member
|
0
:private
|
:public
|
:enabled
|
:anonymous
|
0
:private
|
:public
|
:private
|
:admin
|
1
:private
|
:public
|
:private
|
:reporter
|
1
:private
|
:public
|
:private
|
:guest
|
1
:private
|
:public
|
:private
|
:non_member
|
0
:private
|
:public
|
:private
|
:anonymous
|
0
:private
|
:public
|
:disabled
|
:admin
|
1
:private
|
:public
|
:disabled
|
:reporter
|
0
:private
|
:public
|
:disabled
|
:guest
|
0
:private
|
:public
|
:disabled
|
:non_member
|
0
:private
|
:public
|
:disabled
|
:anonymous
|
0
:private
|
:internal
|
:enabled
|
:admin
|
1
:private
|
:internal
|
:enabled
|
:reporter
|
1
:private
|
:internal
|
:enabled
|
:guest
|
1
:private
|
:internal
|
:enabled
|
:non_member
|
0
:private
|
:internal
|
:enabled
|
:anonymous
|
0
:private
|
:internal
|
:private
|
:admin
|
1
:private
|
:internal
|
:private
|
:reporter
|
1
:private
|
:internal
|
:private
|
:guest
|
1
:private
|
:internal
|
:private
|
:non_member
|
0
:private
|
:internal
|
:private
|
:anonymous
|
0
:private
|
:internal
|
:disabled
|
:admin
|
1
:private
|
:internal
|
:disabled
|
:reporter
|
0
:private
|
:internal
|
:disabled
|
:guest
|
0
:private
|
:internal
|
:disabled
|
:non_member
|
0
:private
|
:internal
|
:disabled
|
:anonymous
|
0
:private
|
:private
|
:private
|
:admin
|
1
:private
|
:private
|
:private
|
:reporter
|
1
:private
|
:private
|
:private
|
:guest
|
1
:private
|
:private
|
:private
|
:non_member
|
0
:private
|
:private
|
:private
|
:anonymous
|
0
:private
|
:private
|
:disabled
|
:admin
|
1
:private
|
:private
|
:disabled
|
:reporter
|
0
:private
|
:private
|
:disabled
|
:guest
|
0
:private
|
:private
|
:disabled
|
:non_member
|
0
:private
|
:private
|
:disabled
|
:anonymous
|
0
end
# :snippet_level, :membership, :expected_count
def
permission_table_for_personal_snippet_access
:public
|
:admin
|
1
:public
|
:author
|
1
:public
|
:non_member
|
1
:public
|
:anonymous
|
1
:internal
|
:admin
|
1
:internal
|
:author
|
1
:internal
|
:non_member
|
1
:internal
|
:anonymous
|
0
:private
|
:admin
|
1
:private
|
:author
|
1
:private
|
:non_member
|
0
:private
|
:anonymous
|
0
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/AbcSize
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