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
bd016fef
Commit
bd016fef
authored
Feb 21, 2020
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only allow group managers to apply licenses
parent
5889b69a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
10 deletions
+34
-10
ee/app/helpers/subscriptions_helper.rb
ee/app/helpers/subscriptions_helper.rb
+1
-1
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+2
-2
ee/spec/models/user_spec.rb
ee/spec/models/user_spec.rb
+31
-7
No files found.
ee/app/helpers/subscriptions_helper.rb
View file @
bd016fef
...
...
@@ -37,7 +37,7 @@ module SubscriptionsHelper
end
def
group_data
current_user
.
free_namespaces
.
map
do
|
namespace
|
current_user
.
managed_
free_namespaces
.
map
do
|
namespace
|
{
id:
namespace
.
id
,
name:
namespace
.
name
,
...
...
ee/app/models/ee/user.rb
View file @
bd016fef
...
...
@@ -240,8 +240,8 @@ module EE
.
any?
end
def
free_namespaces
authorized
_groups
.
with_counts
(
archived:
false
).
where
(
plan:
[
nil
,
Plan
.
free
,
Plan
.
default
]).
order
(
:name
)
def
managed_
free_namespaces
manageable
_groups
.
with_counts
(
archived:
false
).
where
(
plan:
[
nil
,
Plan
.
free
,
Plan
.
default
]).
order
(
:name
)
end
override
:has_current_license?
...
...
ee/spec/models/user_spec.rb
View file @
bd016fef
...
...
@@ -906,30 +906,54 @@ describe User do
end
end
describe
'#free_namespaces'
do
let_it_be
(
:user
)
{
create
(
:user
,
:external
)
}
describe
'#
managed_
free_namespaces'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:licensed_group
)
{
create
(
:group
,
plan: :bronze_plan
)
}
let_it_be
(
:free_group_z
)
{
create
(
:group
,
plan: :default_plan
,
name:
'Z'
)
}
let_it_be
(
:free_group_a
)
{
create
(
:group
,
plan: :default_plan
,
name:
'A'
)
}
subject
{
user
.
free_namespaces
}
subject
{
user
.
managed_
free_namespaces
}
context
'user with no groups'
do
it
{
is_expected
.
to
eq
[]
}
end
context
'
memb
er of a licensed group'
do
context
'
own
er of a licensed group'
do
before
do
licensed_group
.
add_
guest
(
user
)
licensed_group
.
add_
owner
(
user
)
end
it
{
is_expected
.
not_to
include
licensed_group
}
end
context
'
member of 2 free groups
'
do
context
'
guest of a free group
'
do
before
do
free_group_a
.
add_guest
(
user
)
free_group_z
.
add_guest
(
user
)
end
it
{
is_expected
.
not_to
include
free_group_a
}
end
context
'developer of a free group'
do
before
do
free_group_a
.
add_developer
(
user
)
end
it
{
is_expected
.
not_to
include
free_group_a
}
end
context
'maintainer of a free group'
do
before
do
free_group_a
.
add_maintainer
(
user
)
end
it
{
is_expected
.
to
include
free_group_a
}
end
context
'owner of 2 free groups'
do
before
do
free_group_a
.
add_owner
(
user
)
free_group_z
.
add_owner
(
user
)
end
it
{
is_expected
.
to
eq
[
free_group_a
,
free_group_z
]
}
...
...
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