diff options
Diffstat (limited to 'spec/helpers/hooks_helper_spec.rb')
-rw-r--r-- | spec/helpers/hooks_helper_spec.rb | 35 |
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..28f6322466f 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: Gitlab::Json.dump([]) + ) + 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(['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)) |