summaryrefslogtreecommitdiff
path: root/spec/models/deployment_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/deployment_spec.rb')
-rw-r--r--spec/models/deployment_spec.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb
index c962b012a4b..5bc61db6d21 100644
--- a/spec/models/deployment_spec.rb
+++ b/spec/models/deployment_spec.rb
@@ -227,6 +227,56 @@ RSpec.describe Deployment do
deployment.skip!
end
end
+
+ describe 'synching status to Jira' do
+ let(:deployment) { create(:deployment) }
+
+ let(:worker) { ::JiraConnect::SyncDeploymentsWorker }
+
+ it 'calls the worker on creation' do
+ expect(worker).to receive(:perform_async).with(Integer)
+
+ deployment
+ end
+
+ it 'does not call the worker for skipped deployments' do
+ expect(deployment).to be_present # warm-up, ignore the creation trigger
+
+ expect(worker).not_to receive(:perform_async)
+
+ deployment.skip!
+ end
+
+ %i[run! succeed! drop! cancel!].each do |event|
+ context "when we call pipeline.#{event}" do
+ it 'triggers a Jira synch worker' do
+ expect(worker).to receive(:perform_async).with(deployment.id)
+
+ deployment.send(event)
+ end
+
+ context 'the feature is disabled' do
+ it 'does not trigger a worker' do
+ stub_feature_flags(jira_sync_deployments: false)
+
+ expect(worker).not_to receive(:perform_async)
+
+ deployment.send(event)
+ end
+ end
+
+ context 'the feature is enabled for this project' do
+ it 'does trigger a worker' do
+ stub_feature_flags(jira_sync_deployments: deployment.project)
+
+ expect(worker).to receive(:perform_async)
+
+ deployment.send(event)
+ end
+ end
+ end
+ end
+ end
end
describe '#success?' do