diff options
Diffstat (limited to 'spec/controllers/admin/hooks_controller_spec.rb')
-rw-r--r-- | spec/controllers/admin/hooks_controller_spec.rb | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/spec/controllers/admin/hooks_controller_spec.rb b/spec/controllers/admin/hooks_controller_spec.rb index 17c4222530d..14f4a2f40e7 100644 --- a/spec/controllers/admin/hooks_controller_spec.rb +++ b/spec/controllers/admin/hooks_controller_spec.rb @@ -17,16 +17,46 @@ RSpec.describe Admin::HooksController do url: "http://example.com", push_events: true, - tag_push_events: true, + tag_push_events: false, repository_update_events: true, - merge_requests_events: true + merge_requests_events: false, + url_variables: [{ key: 'token', value: 'some secret value' }] } post :create, params: { hook: hook_params } expect(response).to have_gitlab_http_status(:found) expect(SystemHook.all.size).to eq(1) - expect(SystemHook.first).to have_attributes(hook_params) + expect(SystemHook.first).to have_attributes(hook_params.except(:url_variables)) + expect(SystemHook.first).to have_attributes(url_variables: { 'token' => 'some secret value' }) + end + end + + describe 'POST #update' do + let!(:hook) { create(:system_hook) } + + it 'sets all parameters' do + hook.update!(url_variables: { 'foo' => 'bar', 'baz' => 'woo' }) + + hook_params = { + url: 'http://example.com/{baz}?token={token}', + enable_ssl_verification: false, + url_variables: [ + { key: 'token', value: 'some secret value' }, + { key: 'foo', value: nil } + ] + } + + put :update, params: { id: hook.id, hook: hook_params } + + hook.reload + + expect(response).to have_gitlab_http_status(:found) + expect(flash[:notice]).to include('successfully updated') + expect(hook).to have_attributes(hook_params.except(:url_variables)) + expect(hook).to have_attributes( + url_variables: { 'token' => 'some secret value', 'baz' => 'woo' } + ) end end |