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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
dfa286c1
Commit
dfa286c1
authored
Sep 02, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix project settings field
parent
e9e8c67f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
11 deletions
+58
-11
CHANGELOG
CHANGELOG
+1
-0
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+13
-11
spec/helpers/projects_helper_spec.rb
spec/helpers/projects_helper_spec.rb
+44
-0
No files found.
CHANGELOG
View file @
dfa286c1
...
@@ -20,6 +20,7 @@ v 8.12.0 (unreleased)
...
@@ -20,6 +20,7 @@ v 8.12.0 (unreleased)
- Rename behaviour to behavior in bug issue template for consistency (ClemMakesApps)
- Rename behaviour to behavior in bug issue template for consistency (ClemMakesApps)
- Remove suggested colors hover underline (ClemMakesApps)
- Remove suggested colors hover underline (ClemMakesApps)
- Shorten task status phrase (ClemMakesApps)
- Shorten task status phrase (ClemMakesApps)
- Fix project visibility level fields on settings
- Add hover color to emoji icon (ClemMakesApps)
- Add hover color to emoji icon (ClemMakesApps)
- Fix branches page dropdown sort alignment (ClemMakesApps)
- Fix branches page dropdown sort alignment (ClemMakesApps)
- Add white background for no readme container (ClemMakesApps)
- Add white background for no readme container (ClemMakesApps)
...
...
app/helpers/projects_helper.rb
View file @
dfa286c1
...
@@ -129,6 +129,19 @@ module ProjectsHelper
...
@@ -129,6 +129,19 @@ module ProjectsHelper
current_user
.
recent_push
(
project_ids
)
current_user
.
recent_push
(
project_ids
)
end
end
def
project_feature_access_select
(
field
)
# Don't show option "everyone with access" if project is private
options
=
project_feature_options
if
@project
.
private?
options
.
delete
(
'Everyone with access'
)
highest_available_option
=
options
.
values
.
max
if
@project
.
project_feature
.
send
(
field
)
==
ProjectFeature
::
ENABLED
end
options
=
options_for_select
(
options
,
selected:
highest_available_option
||
@project
.
project_feature
.
public_send
(
field
))
content_tag
(
:select
,
options
,
name:
"project[project_feature_attributes][
#{
field
.
to_s
}
]"
,
id:
"project_project_feature_attributes_
#{
field
.
to_s
}
"
,
class:
"pull-right form-control"
,
data:
{
field:
field
}).
html_safe
end
private
private
def
get_project_nav_tabs
(
project
,
current_user
)
def
get_project_nav_tabs
(
project
,
current_user
)
...
@@ -422,15 +435,4 @@ module ProjectsHelper
...
@@ -422,15 +435,4 @@ module ProjectsHelper
'Everyone with access'
=>
ProjectFeature
::
ENABLED
'Everyone with access'
=>
ProjectFeature
::
ENABLED
}
}
end
end
def
project_feature_access_select
(
field
)
# Don't show option "everyone with access" if project is private
options
=
project_feature_options
level
=
@project
.
project_feature
.
public_send
(
field
)
options
.
delete
(
'Everyone with access'
)
if
@project
.
private?
&&
level
!=
ProjectFeature
::
ENABLED
options
=
options_for_select
(
options
,
selected:
@project
.
project_feature
.
public_send
(
field
)
||
ProjectFeature
::
ENABLED
)
content_tag
(
:select
,
options
,
name:
"project[project_feature_attributes][
#{
field
.
to_s
}
]"
,
id:
"project_project_feature_attributes_
#{
field
.
to_s
}
"
,
class:
"pull-right form-control"
,
data:
{
field:
field
}).
html_safe
end
end
end
spec/helpers/projects_helper_spec.rb
View file @
dfa286c1
...
@@ -174,4 +174,48 @@ describe ProjectsHelper do
...
@@ -174,4 +174,48 @@ describe ProjectsHelper do
end
end
end
end
end
end
describe
"#project_feature_access_select"
do
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
let
(
:user
)
{
create
(
:user
)
}
context
"when project is internal or public"
do
it
"shows all options"
do
helper
.
instance_variable_set
(
:@project
,
project
)
result
=
helper
.
project_feature_access_select
(
:issues_access_level
)
expect
(
result
).
to
include
(
"Disabled"
)
expect
(
result
).
to
include
(
"Only team members"
)
expect
(
result
).
to
include
(
"Everyone with access"
)
end
end
context
"when project is private"
do
before
{
project
.
update_attributes
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
}
it
"shows only allowed options"
do
helper
.
instance_variable_set
(
:@project
,
project
)
result
=
helper
.
project_feature_access_select
(
:issues_access_level
)
expect
(
result
).
to
include
(
"Disabled"
)
expect
(
result
).
to
include
(
"Only team members"
)
expect
(
result
).
not_to
include
(
"Everyone with access"
)
end
end
context
"when project moves from public to private"
do
before
do
project
.
project_feature
.
update_attributes
(
issues_access_level:
ProjectFeature
::
ENABLED
)
project
.
update_attributes
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
it
"shows the highest allowed level selected"
do
helper
.
instance_variable_set
(
:@project
,
project
)
result
=
helper
.
project_feature_access_select
(
:issues_access_level
)
expect
(
result
).
to
include
(
"Disabled"
)
expect
(
result
).
to
include
(
"Only team members"
)
expect
(
result
).
not_to
include
(
"Everyone with access"
)
expect
(
result
).
to
have_selector
(
'option[selected]'
,
text:
"Only team members"
)
end
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