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
a5bab14d
Commit
a5bab14d
authored
Apr 12, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
fe9b9f55
336825c3
Changes
5
Hide 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 @
a5bab14d
...
...
@@ -62,13 +62,17 @@ module Groups
end
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
)
return
false
end
true
end
def
visibility_level
params
[
:visibility
].
present?
?
Gitlab
::
VisibilityLevel
.
level_value
(
params
[
:visibility
])
:
params
[
:visibility_level
]
end
end
end
...
...
changelogs/unreleased/fix-api-group-visibility.yml
0 → 100644
View file @
a5bab14d
---
title
:
Fix api group visibility
merge_request
:
26896
author
:
type
:
fixed
lib/gitlab/visibility_level.rb
View file @
a5bab14d
...
...
@@ -75,8 +75,8 @@ module Gitlab
user
.
admin?
||
allowed_level?
(
level
.
to_i
)
end
# Level should be a numeric value, e.g. `20`
# 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
)
valid_level?
(
level
)
&&
non_restricted_level?
(
level
)
end
...
...
spec/lib/gitlab/visibility_level_spec.rb
View file @
a5bab14d
...
...
@@ -85,4 +85,12 @@ describe Gitlab::VisibilityLevel do
.
to
eq
(
described_class
::
PRIVATE
)
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
spec/services/groups/create_service_spec.rb
View file @
a5bab14d
...
...
@@ -88,6 +88,17 @@ describe Groups::CreateService, '#execute' do
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
let!
(
:params
)
{
group_params
.
merge
(
create_chat_team:
"true"
)
}
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