diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2016-11-14 14:44:27 +0100 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2016-11-14 15:22:06 +0100 |
commit | 76bd09326fe070d4c865b6fbc1718673d096c178 (patch) | |
tree | 51cdbf23ce1e1beeebc84b9e95a5b8f9eeb6ac66 /lib/api/project_hooks.rb | |
parent | 36fa5d660df96c49484cd27695da1df6e361eb8f (diff) | |
download | gitlab-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.rb | 10 |
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? |