Commit 337ced28 authored by Alexis Reigel's avatar Alexis Reigel

reference triggers.values for permitted parameters

parent eb5e0e92
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment