diff options
Diffstat (limited to 'spec/services/web_hook_service_spec.rb')
-rw-r--r-- | spec/services/web_hook_service_spec.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/spec/services/web_hook_service_spec.rb b/spec/services/web_hook_service_spec.rb index fed3ae7a543..551c3dbcc82 100644 --- a/spec/services/web_hook_service_spec.rb +++ b/spec/services/web_hook_service_spec.rb @@ -75,7 +75,8 @@ RSpec.describe WebHookService, :request_store, :clean_gitlab_redis_shared_state 'Content-Type' => 'application/json', 'User-Agent' => "GitLab/#{Gitlab::VERSION}", 'X-Gitlab-Event' => 'Push Hook', - 'X-Gitlab-Event-UUID' => uuid + 'X-Gitlab-Event-UUID' => uuid, + 'X-Gitlab-Instance' => Gitlab.config.gitlab.base_url } end @@ -164,7 +165,7 @@ RSpec.describe WebHookService, :request_store, :clean_gitlab_redis_shared_state end end - it 'POSTs the data as JSON' do + it 'POSTs the data as JSON and returns expected headers' do stub_full_request(project_hook.url, method: :post) service_instance.execute @@ -174,6 +175,22 @@ RSpec.describe WebHookService, :request_store, :clean_gitlab_redis_shared_state ).once end + context 'when webhooks_gitlab_instance_header flag is disabled' do + before do + stub_feature_flags(webhooks_gitlab_instance_header: false) + end + + it 'excludes the X-Gitlab-Instance header' do + stub_full_request(project_hook.url, method: :post) + + service_instance.execute + + expect(WebMock).to have_requested(:post, stubbed_hostname(project_hook.url)).with( + headers: headers.except('X-Gitlab-Instance') + ).once + end + end + context 'when the data is a Gitlab::DataBuilder::Pipeline' do let(:pipeline) { create(:ci_pipeline, project: project) } let(:data) { ::Gitlab::DataBuilder::Pipeline.new(pipeline) } |