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
Boxiang Sun
gitlab-ce
Commits
dc00fa90
Commit
dc00fa90
authored
Apr 12, 2019
by
Sara Ahbabou
Committed by
Michael Kozono
Apr 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Squashed commits and modified visibility level output
Added changelog and rebased
parent
d25cdca6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
2 deletions
+30
-2
app/services/groups/create_service.rb
app/services/groups/create_service.rb
+5
-1
changelogs/unreleased/fix-api-group-visibility.yml
changelogs/unreleased/fix-api-group-visibility.yml
+5
-0
lib/gitlab/visibility_level.rb
lib/gitlab/visibility_level.rb
+1
-1
spec/lib/gitlab/visibility_level_spec.rb
spec/lib/gitlab/visibility_level_spec.rb
+8
-0
spec/services/groups/create_service_spec.rb
spec/services/groups/create_service_spec.rb
+11
-0
No files found.
app/services/groups/create_service.rb
View file @
dc00fa90
...
@@ -62,12 +62,16 @@ module Groups
...
@@ -62,12 +62,16 @@ module Groups
end
end
def
can_use_visibility_level?
def
can_use_visibility_level?
unless
Gitlab
::
VisibilityLevel
.
allowed_for?
(
current_user
,
params
[
:visibility_level
]
)
unless
Gitlab
::
VisibilityLevel
.
allowed_for?
(
current_user
,
visibility_level
)
deny_visibility_level
(
@group
)
deny_visibility_level
(
@group
)
return
false
return
false
end
end
true
true
end
end
def
visibility_level
params
[
:visibility
].
present?
?
Gitlab
::
VisibilityLevel
.
level_value
(
params
[
:visibility
])
:
params
[
:visibility_level
]
end
end
end
end
end
changelogs/unreleased/fix-api-group-visibility.yml
0 → 100644
View file @
dc00fa90
---
title
:
Fix api group visibility
merge_request
:
26896
author
:
type
:
fixed
lib/gitlab/visibility_level.rb
View file @
dc00fa90
...
@@ -75,8 +75,8 @@ module Gitlab
...
@@ -75,8 +75,8 @@ module Gitlab
user
.
admin?
||
allowed_level?
(
level
.
to_i
)
user
.
admin?
||
allowed_level?
(
level
.
to_i
)
end
end
# Level should be a numeric value, e.g. `20`
# Return true if the specified level is allowed for the current user.
# Return true if the specified level is allowed for the current user.
# Level should be a numeric value, e.g. `20`.
def
allowed_level?
(
level
)
def
allowed_level?
(
level
)
valid_level?
(
level
)
&&
non_restricted_level?
(
level
)
valid_level?
(
level
)
&&
non_restricted_level?
(
level
)
end
end
...
...
spec/lib/gitlab/visibility_level_spec.rb
View file @
dc00fa90
...
@@ -85,4 +85,12 @@ describe Gitlab::VisibilityLevel do
...
@@ -85,4 +85,12 @@ describe Gitlab::VisibilityLevel do
.
to
eq
(
described_class
::
PRIVATE
)
.
to
eq
(
described_class
::
PRIVATE
)
end
end
end
end
describe
'.valid_level?'
do
it
'returns true when visibility is valid'
do
expect
(
described_class
.
valid_level?
(
described_class
::
PRIVATE
)).
to
be_truthy
expect
(
described_class
.
valid_level?
(
described_class
::
INTERNAL
)).
to
be_truthy
expect
(
described_class
.
valid_level?
(
described_class
::
PUBLIC
)).
to
be_truthy
end
end
end
end
spec/services/groups/create_service_spec.rb
View file @
dc00fa90
...
@@ -88,6 +88,17 @@ describe Groups::CreateService, '#execute' do
...
@@ -88,6 +88,17 @@ describe Groups::CreateService, '#execute' do
end
end
end
end
describe
"when visibility level is passed as a string"
do
let
(
:service
)
{
described_class
.
new
(
user
,
group_params
)
}
let
(
:group_params
)
{
{
path:
'group_path'
,
visibility:
'public'
}
}
it
"assigns the correct visibility level"
do
group
=
service
.
execute
expect
(
group
.
visibility_level
).
to
eq
(
Gitlab
::
VisibilityLevel
::
PUBLIC
)
end
end
describe
'creating a mattermost team'
do
describe
'creating a mattermost team'
do
let!
(
:params
)
{
group_params
.
merge
(
create_chat_team:
"true"
)
}
let!
(
:params
)
{
group_params
.
merge
(
create_chat_team:
"true"
)
}
let!
(
:service
)
{
described_class
.
new
(
user
,
params
)
}
let!
(
:service
)
{
described_class
.
new
(
user
,
params
)
}
...
...
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