Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/web_hook_service_spec.rb')
-rw-r--r--spec/services/web_hook_service_spec.rb43
1 files changed, 21 insertions, 22 deletions
diff --git a/spec/services/web_hook_service_spec.rb b/spec/services/web_hook_service_spec.rb
index 551c3dbcc82..c081b20d95f 100644
--- a/spec/services/web_hook_service_spec.rb
+++ b/spec/services/web_hook_service_spec.rb
@@ -175,22 +175,6 @@ 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) }
@@ -245,7 +229,7 @@ RSpec.describe WebHookService, :request_store, :clean_gitlab_redis_shared_state
it 'does not execute disabled hooks' do
allow(service_instance).to receive(:disabled?).and_return(true)
- expect(service_instance.execute).to eq({ status: :error, message: 'Hook disabled' })
+ expect(service_instance.execute).to have_attributes(status: :error, message: 'Hook disabled')
end
it 'executes and registers the hook with the recursion detection', :aggregate_failures do
@@ -317,7 +301,8 @@ RSpec.describe WebHookService, :request_store, :clean_gitlab_redis_shared_state
project_hook.enable!
stub_full_request(project_hook.url, method: :post).to_raise(exception)
- expect(service_instance.execute).to eq({ status: :error, message: exception.to_s })
+
+ expect(service_instance.execute).to have_attributes(status: :error, message: exception.to_s)
expect { service_instance.execute }.not_to raise_error
end
end
@@ -326,7 +311,10 @@ RSpec.describe WebHookService, :request_store, :clean_gitlab_redis_shared_state
let_it_be(:project_hook) { create(:project_hook, url: 'http://server.com/my path/') }
it 'handles exceptions' do
- expect(service_instance.execute).to eq(status: :error, message: 'bad URI(is not URI?): "http://server.com/my path/"')
+ expect(service_instance.execute).to have_attributes(
+ status: :error,
+ message: 'bad URI(is not URI?): "http://server.com/my path/"'
+ )
expect { service_instance.execute }.not_to raise_error
end
end
@@ -335,20 +323,31 @@ RSpec.describe WebHookService, :request_store, :clean_gitlab_redis_shared_state
it 'does not perform the request' do
stub_const("#{described_class}::REQUEST_BODY_SIZE_LIMIT", 10.bytes)
- expect(service_instance.execute).to eq({ status: :error, message: "Gitlab::Json::LimitedEncoder::LimitExceeded" })
+ expect(service_instance.execute).to have_attributes(
+ status: :error,
+ message: 'Gitlab::Json::LimitedEncoder::LimitExceeded'
+ )
end
end
it 'handles 200 status code' do
stub_full_request(project_hook.url, method: :post).to_return(status: 200, body: 'Success')
- expect(service_instance.execute).to include({ status: :success, http_status: 200, message: 'Success' })
+ expect(service_instance.execute).to have_attributes(
+ status: :success,
+ payload: { http_status: 200 },
+ message: 'Success'
+ )
end
it 'handles 2xx status codes' do
stub_full_request(project_hook.url, method: :post).to_return(status: 201, body: 'Success')
- expect(service_instance.execute).to include({ status: :success, http_status: 201, message: 'Success' })
+ expect(service_instance.execute).to have_attributes(
+ status: :success,
+ payload: { http_status: 201 },
+ message: 'Success'
+ )
end
context 'execution logging' do