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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-17 14:33:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-17 14:33:21 +0300
commit7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch)
tree5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/helpers/hooks_helper_spec.rb
parent185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff)
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/helpers/hooks_helper_spec.rb')
-rw-r--r--spec/helpers/hooks_helper_spec.rb35
1 files changed, 26 insertions, 9 deletions
diff --git a/spec/helpers/hooks_helper_spec.rb b/spec/helpers/hooks_helper_spec.rb
index 8f438a3ddc8..98a1f77b414 100644
--- a/spec/helpers/hooks_helper_spec.rb
+++ b/spec/helpers/hooks_helper_spec.rb
@@ -3,16 +3,33 @@
require 'spec_helper'
RSpec.describe HooksHelper do
- let(:project) { create(:project) }
- let(:project_hook) { create(:project_hook, project: project) }
- let(:service_hook) { create(:service_hook, integration: create(:drone_ci_integration)) }
- let(:system_hook) { create(:system_hook) }
+ let(:project) { build_stubbed(:project) }
+ let(:project_hook) { build_stubbed(:project_hook, project: project) }
+ let(:service_hook) { build_stubbed(:service_hook, integration: build_stubbed(:drone_ci_integration)) }
+ let(:system_hook) { build_stubbed(:system_hook) }
describe '#webhook_form_data' do
subject { helper.webhook_form_data(project_hook) }
- it { expect(subject[:url]).to eq(project_hook.url) }
- it { expect(subject[:url_variables]).to be_nil }
+ context 'when there are no URL variables' do
+ it 'returns proper data' do
+ expect(subject).to match(
+ url: project_hook.url,
+ url_variables: "[]"
+ )
+ end
+ end
+
+ context 'when there are URL variables' do
+ let(:project_hook) { build_stubbed(:project_hook, :url_variables, project: project) }
+
+ it 'returns proper data' do
+ expect(subject).to match(
+ url: project_hook.url,
+ url_variables: Gitlab::Json.dump([{ key: 'abc' }])
+ )
+ end
+ end
end
describe '#link_to_test_hook' do
@@ -31,7 +48,7 @@ RSpec.describe HooksHelper do
describe '#hook_log_path' do
context 'with a project hook' do
- let(:web_hook_log) { create(:web_hook_log, web_hook: project_hook) }
+ let(:web_hook_log) { build_stubbed(:web_hook_log, web_hook: project_hook) }
it 'returns project-namespaced link' do
expect(helper.hook_log_path(project_hook, web_hook_log))
@@ -40,7 +57,7 @@ RSpec.describe HooksHelper do
end
context 'with a service hook' do
- let(:web_hook_log) { create(:web_hook_log, web_hook: service_hook) }
+ let(:web_hook_log) { build_stubbed(:web_hook_log, web_hook: service_hook) }
it 'returns project-namespaced link' do
expect(helper.hook_log_path(project_hook, web_hook_log))
@@ -49,7 +66,7 @@ RSpec.describe HooksHelper do
end
context 'with a system hook' do
- let(:web_hook_log) { create(:web_hook_log, web_hook: system_hook) }
+ let(:web_hook_log) { build_stubbed(:web_hook_log, web_hook: system_hook) }
it 'returns admin-namespaced link' do
expect(helper.hook_log_path(system_hook, web_hook_log))