reference triggers.values for permitted parameters

This commit is contained in:
Alexis Reigel 2017-12-18 11:14:51 +01:00
parent eb5e0e921c
commit 337ced28bc
4 changed files with 33 additions and 17 deletions

View file

@ -59,12 +59,9 @@ class Admin::HooksController < Admin::ApplicationController
def hook_params
params.require(:hook).permit(
:enable_ssl_verification,
:push_events,
:tag_push_events,
:repository_update_events,
:merge_requests_events,
:token,
:url
:url,
*SystemHook.triggers.values
)
end
end

View file

@ -63,18 +63,10 @@ class Projects::HooksController < Projects::ApplicationController
def hook_params
params.require(:hook).permit(
:job_events,
:pipeline_events,
:enable_ssl_verification,
:issues_events,
:confidential_issues_events,
:merge_requests_events,
:note_events,
:push_events,
:tag_push_events,
:token,
:url,
:wiki_page_events
*ProjectHook.triggers.values
)
end
end

View file

@ -11,12 +11,13 @@ describe Admin::HooksController do
it 'sets all parameters' do
hook_params = {
enable_ssl_verification: true,
token: "TEST TOKEN",
url: "http://example.com",
push_events: true,
tag_push_events: true,
repository_update_events: true,
merge_requests_events: true,
token: "TEST TOKEN",
url: "http://example.com"
merge_requests_events: true
}
post :create, hook: hook_params

View file

@ -18,4 +18,30 @@ describe Projects::HooksController do
)
end
end
describe '#create' do
it 'sets all parameters' do
hook_params = {
enable_ssl_verification: true,
token: "TEST TOKEN",
url: "http://example.com",
push_events: true,
tag_push_events: true,
merge_requests_events: true,
issues_events: true,
confidential_issues_events: true,
note_events: true,
job_events: true,
pipeline_events: true,
wiki_page_events: true
}
post :create, namespace_id: project.namespace, project_id: project, hook: hook_params
expect(response).to have_http_status(302)
expect(ProjectHook.all.size).to eq(1)
expect(ProjectHook.first).to have_attributes(hook_params)
end
end
end