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
6a0a4dfe
Commit
6a0a4dfe
authored
May 23, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use delegate so that we set shared_runners_minutes_limit
from the user directly rather than from the namespace.
parent
2b71995e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
15 deletions
+6
-15
app/models/user.rb
app/models/user.rb
+3
-1
lib/api/entities.rb
lib/api/entities.rb
+0
-5
lib/api/users.rb
lib/api/users.rb
+1
-7
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+2
-2
No files found.
app/models/user.rb
View file @
6a0a4dfe
...
...
@@ -63,7 +63,7 @@ class User < ActiveRecord::Base
#
# Namespace for personal projects
has_one
:namespace
,
->
{
where
type:
nil
},
dependent: :destroy
,
foreign_key: :owner_id
has_one
:namespace
,
->
{
where
type:
nil
},
dependent: :destroy
,
foreign_key: :owner_id
,
autosave:
true
# Profile
has_many
:keys
,
->
do
...
...
@@ -182,6 +182,8 @@ class User < ActiveRecord::Base
alias_attribute
:private_token
,
:authentication_token
delegate
:path
,
to: :namespace
,
allow_nil:
true
,
prefix:
true
delegate
:shared_runners_minutes_limit
,
:shared_runners_minutes_limit
=
,
to: :namespace
accepts_nested_attributes_for
:namespace
...
...
lib/api/entities.rb
View file @
6a0a4dfe
...
...
@@ -40,11 +40,6 @@ module API
expose
:external
# EE-only
expose
:namespace
,
using:
'API::Entities::UserNamespace'
end
# EE-only
class
UserNamespace
<
Grape
::
Entity
expose
:shared_runners_minutes_limit
end
...
...
lib/api/users.rb
View file @
6a0a4dfe
...
...
@@ -32,11 +32,9 @@ module API
all_or_none_of
:extern_uid
,
:provider
# EE
optional
:namespace_attributes
,
type:
Hash
do
optional
:shared_runners_minutes_limit
,
type:
Integer
,
desc:
'Pipeline minutes quota for this user'
end
end
end
desc
'Get the list of users'
do
success
Entities
::
UserBasic
...
...
@@ -175,10 +173,6 @@ module API
user_params
[
:password_expires_at
]
=
Time
.
now
if
user_params
[
:password
].
present?
# EE
namespace_attributes
=
user_params
[
:namespace_attributes
]
namespace_attributes
[
:id
]
=
user
.
namespace_id
if
namespace_attributes
if
user
.
update_attributes
(
user_params
.
except
(
:extern_uid
,
:provider
))
present
user
,
with:
Entities
::
UserPublic
else
...
...
spec/requests/api/users_spec.rb
View file @
6a0a4dfe
...
...
@@ -426,10 +426,10 @@ describe API::Users do
end
it
"updates shared_runners_minutes_limit"
do
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
{
namespace_attributes:
{
shared_runners_minutes_limit:
133
}
}
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
{
shared_runners_minutes_limit:
133
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
.
dig
(
'namespace'
,
'shared_runners_minutes_limit'
)
)
expect
(
json_response
[
'shared_runners_minutes_limit'
]
)
.
to
eq
(
133
)
expect
(
user
.
reload
.
namespace
.
shared_runners_minutes_limit
).
to
eq
(
133
)
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