summaryrefslogtreecommitdiff
path: root/lib/api/project_hooks.rb
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2016-11-14 14:44:27 +0100
committerRobert Schilling <rschilling@student.tugraz.at>2016-11-14 15:22:06 +0100
commit76bd09326fe070d4c865b6fbc1718673d096c178 (patch)
tree51cdbf23ce1e1beeebc84b9e95a5b8f9eeb6ac66 /lib/api/project_hooks.rb
parent36fa5d660df96c49484cd27695da1df6e361eb8f (diff)
downloadgitlab-ce-76bd09326fe070d4c865b6fbc1718673d096c178.tar.gz
Use declared_params helper in APIgrapify-declared-params
Diffstat (limited to 'lib/api/project_hooks.rb')
-rw-r--r--lib/api/project_hooks.rb10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/api/project_hooks.rb b/lib/api/project_hooks.rb
index eef343c2ac6..2b36ef7c426 100644
--- a/lib/api/project_hooks.rb
+++ b/lib/api/project_hooks.rb
@@ -51,8 +51,7 @@ module API
use :project_hook_properties
end
post ":id/hooks" do
- new_hook_params = declared(params, include_missing: false, include_parent_namespaces: false).to_h
- hook = user_project.hooks.new(new_hook_params)
+ hook = user_project.hooks.new(declared_params(include_missing: false))
if hook.save
present hook, with: Entities::ProjectHook
@@ -71,12 +70,9 @@ module API
use :project_hook_properties
end
put ":id/hooks/:hook_id" do
- hook = user_project.hooks.find(params[:hook_id])
-
- new_params = declared(params, include_missing: false, include_parent_namespaces: false).to_h
- new_params.delete('hook_id')
+ hook = user_project.hooks.find(params.delete(:hook_id))
- if hook.update_attributes(new_params)
+ if hook.update_attributes(declared_params(include_missing: false))
present hook, with: Entities::ProjectHook
else
error!("Invalid url given", 422) if hook.errors[:url].present?