diff options
Diffstat (limited to 'spec/services/test_hooks/project_service_spec.rb')
-rw-r--r-- | spec/services/test_hooks/project_service_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/services/test_hooks/project_service_spec.rb b/spec/services/test_hooks/project_service_spec.rb index e4cc3a2d652..7470bdff527 100644 --- a/spec/services/test_hooks/project_service_spec.rb +++ b/spec/services/test_hooks/project_service_spec.rb @@ -186,5 +186,23 @@ RSpec.describe TestHooks::ProjectService do expect(service.execute).to include(success_result) end end + + context 'releases_events' do + let(:trigger) { 'releases_events' } + let(:trigger_key) { :release_hooks } + + it 'returns error message if not enough data' do + expect(hook).not_to receive(:execute) + expect(service.execute).to include({ status: :error, message: 'Ensure the project has releases.' }) + end + + it 'executes hook' do + allow(project).to receive(:releases).and_return([Release.new]) + allow_any_instance_of(Release).to receive(:to_hook_data).and_return(sample_data) + + expect(hook).to receive(:execute).with(sample_data, trigger_key).and_return(success_result) + expect(service.execute).to include(success_result) + end + end end end |