diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 21:09:04 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 21:09:04 +0000 |
commit | 40e8ba2fc8ac6c3695d7f297ff4143518615a3f9 (patch) | |
tree | ed39c719819b3f2a5e6216f2221cb31bbac3f62c /spec/controllers/projects/hooks_controller_spec.rb | |
parent | a3764262c04bafcd6a54aff635541d73a8a630fd (diff) | |
download | gitlab-ce-40e8ba2fc8ac6c3695d7f297ff4143518615a3f9.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers/projects/hooks_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/hooks_controller_spec.rb | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/spec/controllers/projects/hooks_controller_spec.rb b/spec/controllers/projects/hooks_controller_spec.rb index ba7b712964c..54c958d6350 100644 --- a/spec/controllers/projects/hooks_controller_spec.rb +++ b/spec/controllers/projects/hooks_controller_spec.rb @@ -106,8 +106,9 @@ RSpec.describe Projects::HooksController do it 'sets all parameters' do hook_params = { enable_ssl_verification: true, - token: "TEST TOKEN", - url: "http://example.com", + token: 'TEST TOKEN', + url: 'http://example.com', + branch_filter_strategy: 'regex', push_events: true, tag_push_events: true, @@ -124,13 +125,39 @@ RSpec.describe Projects::HooksController do url_variables: [{ key: 'token', value: 'some secret value' }] } - post :create, params: { namespace_id: project.namespace, project_id: project, hook: hook_params } + params = { namespace_id: project.namespace, project_id: project, hook: hook_params } + + expect { post :create, params: params }.to change(ProjectHook, :count).by(1) + + project_hook = ProjectHook.order_id_desc.take + + expect(project_hook).to have_attributes( + **hook_params.merge(url_variables: { 'token' => 'some secret value' }) + ) + expect(response).to have_gitlab_http_status(:found) + expect(flash[:alert]).to be_blank + end + + it 'ignores branch_filter_strategy when flag is disabled' do + stub_feature_flags(enhanced_webhook_support_regex: false) + hook_params = { + url: 'http://example.com', + branch_filter_strategy: 'regex', + push_events: true + } + params = { namespace_id: project.namespace, project_id: project, hook: hook_params } + + expect { post :create, params: params }.to change(ProjectHook, :count).by(1) + + project_hook = ProjectHook.order_id_desc.take + + expect(project_hook).to have_attributes( + url: 'http://example.com', + branch_filter_strategy: 'wildcard' + ) expect(response).to have_gitlab_http_status(:found) expect(flash[:alert]).to be_blank - expect(ProjectHook.count).to eq(1) - expect(ProjectHook.first).to have_attributes(hook_params.except(:url_variables)) - expect(ProjectHook.first).to have_attributes(url_variables: { 'token' => 'some secret value' }) end it 'alerts the user if the new hook is invalid' do |