BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d69deb1d
Commit
d69deb1d
authored
Apr 17, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/project-visibility-setting' into 'master'
Fix restricted visibility project setting Closes #30581 See merge request !10622
parents
9927cc9b
878e46a1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
5 deletions
+41
-5
projects_helper.rb
app/helpers/projects_helper.rb
+14
-5
fix-project-visibility-setting.yml
changelogs/unreleased/fix-project-visibility-setting.yml
+4
-0
projects_helper_spec.rb
spec/helpers/projects_helper_spec.rb
+23
-0
No files found.
app/helpers/projects_helper.rb
View file @
d69deb1d
...
@@ -24,7 +24,7 @@ module ProjectsHelper
...
@@ -24,7 +24,7 @@ module ProjectsHelper
return
"(deleted)"
unless
author
return
"(deleted)"
unless
author
author_html
=
""
author_html
=
""
# Build avatar image tag
# Build avatar image tag
author_html
<<
image_tag
(
avatar_icon
(
author
,
opts
[
:size
]),
width:
opts
[
:size
],
class:
"avatar avatar-inline
#{
"s
#{
opts
[
:size
]
}
"
if
opts
[
:size
]
}
#{
opts
[
:avatar_class
]
if
opts
[
:avatar_class
]
}
"
,
alt:
''
)
if
opts
[
:avatar
]
author_html
<<
image_tag
(
avatar_icon
(
author
,
opts
[
:size
]),
width:
opts
[
:size
],
class:
"avatar avatar-inline
#{
"s
#{
opts
[
:size
]
}
"
if
opts
[
:size
]
}
#{
opts
[
:avatar_class
]
if
opts
[
:avatar_class
]
}
"
,
alt:
''
)
if
opts
[
:avatar
]
...
@@ -45,7 +45,7 @@ module ProjectsHelper
...
@@ -45,7 +45,7 @@ module ProjectsHelper
link_to
(
author_html
,
user_path
(
author
),
class:
"author_link
#{
"
#{
opts
[
:extra_class
]
}
"
if
opts
[
:extra_class
]
}
#{
"
#{
opts
[
:mobile_classes
]
}
"
if
opts
[
:mobile_classes
]
}
"
).
html_safe
link_to
(
author_html
,
user_path
(
author
),
class:
"author_link
#{
"
#{
opts
[
:extra_class
]
}
"
if
opts
[
:extra_class
]
}
#{
"
#{
opts
[
:mobile_classes
]
}
"
if
opts
[
:mobile_classes
]
}
"
).
html_safe
else
else
title
=
opts
[
:title
].
sub
(
":name"
,
sanitize
(
author
.
name
))
title
=
opts
[
:title
].
sub
(
":name"
,
sanitize
(
author
.
name
))
link_to
(
author_html
,
user_path
(
author
),
class:
"author_link has-tooltip"
,
title:
title
,
data:
{
container:
'body'
}
).
html_safe
link_to
(
author_html
,
user_path
(
author
),
class:
"author_link has-tooltip"
,
title:
title
,
data:
{
container:
'body'
}).
html_safe
end
end
end
end
...
@@ -430,13 +430,22 @@ module ProjectsHelper
...
@@ -430,13 +430,22 @@ module ProjectsHelper
end
end
def
visibility_select_options
(
project
,
selected_level
)
def
visibility_select_options
(
project
,
selected_level
)
levels_options_array
=
Gitlab
::
VisibilityLevel
.
values
.
map
do
|
level
|
level_options
=
Gitlab
::
VisibilityLevel
.
values
.
each_with_object
([])
do
|
level
,
level_options
|
[
next
if
restricted_levels
.
include?
(
level
)
level_options
<<
[
visibility_level_label
(
level
),
visibility_level_label
(
level
),
{
data:
{
description:
visibility_level_description
(
level
,
project
)
}
},
{
data:
{
description:
visibility_level_description
(
level
,
project
)
}
},
level
level
]
]
end
end
options_for_select
(
levels_options_array
,
selected_level
)
options_for_select
(
level_options
,
selected_level
)
end
def
restricted_levels
return
[]
if
current_user
.
admin?
current_application_settings
.
restricted_visibility_levels
||
[]
end
end
end
end
changelogs/unreleased/fix-project-visibility-setting.yml
0 → 100644
View file @
d69deb1d
---
title
:
Fix restricted project visibility setting available to users
merge_request
:
author
:
spec/helpers/projects_helper_spec.rb
View file @
d69deb1d
...
@@ -265,4 +265,27 @@ describe ProjectsHelper do
...
@@ -265,4 +265,27 @@ describe ProjectsHelper do
end
end
end
end
end
end
describe
"#visibility_select_options"
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
stub_application_setting
(
restricted_visibility_levels:
[
Gitlab
::
VisibilityLevel
::
PUBLIC
])
end
it
"does not include the Public restricted level"
do
expect
(
helper
.
send
(
:visibility_select_options
,
project
,
Gitlab
::
VisibilityLevel
::
PRIVATE
)).
not_to
include
(
'Public'
)
end
it
"includes the Internal level"
do
expect
(
helper
.
send
(
:visibility_select_options
,
project
,
Gitlab
::
VisibilityLevel
::
PRIVATE
)).
to
include
(
'Internal'
)
end
it
"includes the Private level"
do
expect
(
helper
.
send
(
:visibility_select_options
,
project
,
Gitlab
::
VisibilityLevel
::
PRIVATE
)).
to
include
(
'Private'
)
end
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