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
510092c8
Commit
510092c8
authored
Nov 10, 2016
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use #to_h to convert params to a hash
parent
87cc458a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
7 deletions
+9
-7
lib/api/helpers.rb
lib/api/helpers.rb
+5
-0
lib/api/milestones.rb
lib/api/milestones.rb
+3
-4
lib/api/runners.rb
lib/api/runners.rb
+1
-3
No files found.
lib/api/helpers.rb
View file @
510092c8
...
@@ -23,6 +23,11 @@ module API
...
@@ -23,6 +23,11 @@ module API
warden
.
try
(
:authenticate
)
if
%w[GET HEAD]
.
include?
(
env
[
'REQUEST_METHOD'
])
warden
.
try
(
:authenticate
)
if
%w[GET HEAD]
.
include?
(
env
[
'REQUEST_METHOD'
])
end
end
def
declared_params
(
options
=
{})
options
=
{
include_parent_namespaces:
false
}.
merge
(
options
)
declared
(
params
,
options
).
to_h
.
symbolize_keys
end
def
find_user_by_private_token
def
find_user_by_private_token
token
=
private_token
token
=
private_token
return
nil
unless
token
.
present?
return
nil
unless
token
.
present?
...
...
lib/api/milestones.rb
View file @
510092c8
...
@@ -62,9 +62,8 @@ module API
...
@@ -62,9 +62,8 @@ module API
end
end
post
":id/milestones"
do
post
":id/milestones"
do
authorize!
:admin_milestone
,
user_project
authorize!
:admin_milestone
,
user_project
milestone_params
=
declared
(
params
,
include_parent_namespaces:
false
)
milestone
=
::
Milestones
::
CreateService
.
new
(
user_project
,
current_user
,
milestone
_params
).
execute
milestone
=
::
Milestones
::
CreateService
.
new
(
user_project
,
current_user
,
declared
_params
).
execute
if
milestone
.
valid?
if
milestone
.
valid?
present
milestone
,
with:
Entities
::
Milestone
present
milestone
,
with:
Entities
::
Milestone
...
@@ -86,9 +85,9 @@ module API
...
@@ -86,9 +85,9 @@ module API
end
end
put
":id/milestones/:milestone_id"
do
put
":id/milestones/:milestone_id"
do
authorize!
:admin_milestone
,
user_project
authorize!
:admin_milestone
,
user_project
milestone
_params
=
declared
(
params
,
include_parent_namespaces:
false
,
include_missing:
false
)
milestone
=
user_project
.
milestones
.
find
(
params
.
delete
(
:milestone_id
)
)
milestone
=
user_project
.
milestones
.
find
(
milestone_params
.
delete
(
:milestone_id
)
)
milestone
_params
=
declared_params
(
include_missing:
false
)
milestone
=
::
Milestones
::
UpdateService
.
new
(
user_project
,
current_user
,
milestone_params
).
execute
(
milestone
)
milestone
=
::
Milestones
::
UpdateService
.
new
(
user_project
,
current_user
,
milestone_params
).
execute
(
milestone
)
if
milestone
.
valid?
if
milestone
.
valid?
...
...
lib/api/runners.rb
View file @
510092c8
...
@@ -57,9 +57,7 @@ module API
...
@@ -57,9 +57,7 @@ module API
runner
=
get_runner
(
params
.
delete
(
:id
))
runner
=
get_runner
(
params
.
delete
(
:id
))
authenticate_update_runner!
(
runner
)
authenticate_update_runner!
(
runner
)
runner_params
=
declared
(
params
,
include_missing:
false
)
if
runner
.
update
(
declared_params
(
include_missing:
false
))
if
runner
.
update
(
runner_params
)
present
runner
,
with:
Entities
::
RunnerDetails
,
current_user:
current_user
present
runner
,
with:
Entities
::
RunnerDetails
,
current_user:
current_user
else
else
render_validation_error!
(
runner
)
render_validation_error!
(
runner
)
...
...
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