diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-04-10 12:05:29 +0200 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-04-12 10:06:57 +0200 |
commit | e415ad3952701cae3cad55c114e1a839ec510478 (patch) | |
tree | f647255dcd3272ffaf37b70230390e23553d46d8 /lib | |
parent | d59f48987baceb25aa87dc6d87551f68af4bb1ed (diff) | |
download | gitlab-ce-e415ad3952701cae3cad55c114e1a839ec510478.tar.gz |
Fix API not accepting job_events for webhookszj-api-fix-build-events
When renaming, the argument on the projects hook API was forgotten. Now
one could successfully set it again.
The fix is a little ugly stylewise, but needed as the underlying model
still refers to it as build_events. This commit is to fix it, later we
should migrate the data to a new column. The edit on the spec file makes
sure it passes now, and will fail when we migrate the column.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/project_hooks.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/api/project_hooks.rb b/lib/api/project_hooks.rb index 53791166c33..87dfd1573a4 100644 --- a/lib/api/project_hooks.rb +++ b/lib/api/project_hooks.rb @@ -13,7 +13,7 @@ module API optional :merge_requests_events, type: Boolean, desc: "Trigger hook on merge request events" optional :tag_push_events, type: Boolean, desc: "Trigger hook on tag push events" optional :note_events, type: Boolean, desc: "Trigger hook on note(comment) events" - optional :build_events, type: Boolean, desc: "Trigger hook on build events" + optional :job_events, type: Boolean, desc: "Trigger hook on job events" optional :pipeline_events, type: Boolean, desc: "Trigger hook on pipeline events" optional :wiki_page_events, type: Boolean, desc: "Trigger hook on wiki events" optional :enable_ssl_verification, type: Boolean, desc: "Do SSL verification when triggering the hook" @@ -53,7 +53,10 @@ module API use :project_hook_properties end post ":id/hooks" do - hook = user_project.hooks.new(declared_params(include_missing: false)) + hook_params = declared_params(include_missing: false) + hook_params[:build_events] = hook_params.delete(:job_events) { false } + + hook = user_project.hooks.new(hook_params) if hook.save present hook, with: Entities::ProjectHook @@ -74,7 +77,10 @@ module API put ":id/hooks/:hook_id" do hook = user_project.hooks.find(params.delete(:hook_id)) - if hook.update_attributes(declared_params(include_missing: false)) + update_params = declared_params(include_missing: false) + update_params[:build_events] = update_params.delete(:job_events) if update_params[:job_events] + + if hook.update_attributes(update_params) present hook, with: Entities::ProjectHook else error!("Invalid url given", 422) if hook.errors[:url].present? |