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
d5be6d90
Commit
d5be6d90
authored
Aug 29, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'visibility-fix' into 'master'
Visibility fix Fixes #1529 See merge request !1049
parents
36361f4e
68fd66c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
lib/gitlab/visibility_level.rb
lib/gitlab/visibility_level.rb
+15
-1
spec/services/projects/update_service_spec.rb
spec/services/projects/update_service_spec.rb
+1
-1
No files found.
lib/gitlab/visibility_level.rb
View file @
d5be6d90
...
...
@@ -23,7 +23,21 @@ module Gitlab
end
def
allowed_for?
(
user
,
level
)
user
.
is_admin?
||
!
Gitlab
.
config
.
gitlab
.
restricted_visibility_levels
.
include?
(
level
)
user
.
is_admin?
||
allowed_level?
(
level
)
end
# Level can be a string `"public"` or a value `20`, first check if valid,
# then check if the corresponding string appears in the config
def
allowed_level?
(
level
)
if
options
.
has_key?
(
level
.
to_s
)
non_restricted_level?
(
level
)
elsif
options
.
has_value?
(
level
.
to_i
)
non_restricted_level?
(
options
.
key
(
level
.
to_i
).
downcase
)
end
end
def
non_restricted_level?
(
level
)
!
Gitlab
.
config
.
gitlab
.
restricted_visibility_levels
.
include?
(
level
)
end
end
...
...
spec/services/projects/update_service_spec.rb
View file @
d5be6d90
...
...
@@ -48,7 +48,7 @@ describe Projects::UpdateService do
context
'respect configured visibility restrictions setting'
do
before
(
:each
)
do
@restrictions
=
double
(
"restrictions"
)
@restrictions
.
stub
(
:restricted_visibility_levels
)
{
[
Gitlab
::
VisibilityLevel
::
PUBLIC
]
}
@restrictions
.
stub
(
:restricted_visibility_levels
)
{
[
"public"
]
}
Settings
.
stub_chain
(
:gitlab
).
and_return
(
@restrictions
)
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