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.rb65
1 files changed, 50 insertions, 15 deletions
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb
index 1c7b11257ce..3e855584c38 100644
--- a/spec/models/deployment_spec.rb
+++ b/spec/models/deployment_spec.rb
@@ -98,16 +98,36 @@ RSpec.describe Deployment do
context 'when deployment runs' do
let(:deployment) { create(:deployment) }
- before do
- deployment.run!
- end
-
it 'starts running' do
freeze_time do
+ deployment.run!
+
expect(deployment).to be_running
expect(deployment.finished_at).to be_nil
end
end
+
+ it 'executes Deployments::ExecuteHooksWorker asynchronously' do
+ expect(Deployments::ExecuteHooksWorker)
+ .to receive(:perform_async).with(deployment.id)
+
+ deployment.run!
+ end
+
+ it 'does not execute Deployments::ExecuteHooksWorker when feature is disabled' do
+ stub_feature_flags(ci_send_deployment_hook_when_start: false)
+ expect(Deployments::ExecuteHooksWorker)
+ .not_to receive(:perform_async).with(deployment.id)
+
+ deployment.run!
+ end
+
+ it 'executes Deployments::DropOlderDeploymentsWorker asynchronously' do
+ expect(Deployments::DropOlderDeploymentsWorker)
+ .to receive(:perform_async).once.with(deployment.id)
+
+ deployment.run!
+ end
end
context 'when deployment succeeded' do
@@ -122,15 +142,15 @@ RSpec.describe Deployment do
end
end
- it 'executes Deployments::SuccessWorker asynchronously' do
- expect(Deployments::SuccessWorker)
+ it 'executes Deployments::UpdateEnvironmentWorker asynchronously' do
+ expect(Deployments::UpdateEnvironmentWorker)
.to receive(:perform_async).with(deployment.id)
deployment.succeed!
end
- it 'executes Deployments::FinishedWorker asynchronously' do
- expect(Deployments::FinishedWorker)
+ it 'executes Deployments::ExecuteHooksWorker asynchronously' do
+ expect(Deployments::ExecuteHooksWorker)
.to receive(:perform_async).with(deployment.id)
deployment.succeed!
@@ -149,12 +169,19 @@ RSpec.describe Deployment do
end
end
- it 'executes Deployments::FinishedWorker asynchronously' do
- expect(Deployments::FinishedWorker)
+ it 'executes Deployments::LinkMergeRequestWorker asynchronously' do
+ expect(Deployments::LinkMergeRequestWorker)
.to receive(:perform_async).with(deployment.id)
deployment.drop!
end
+
+ it 'executes Deployments::ExecuteHooksWorker asynchronously' do
+ expect(Deployments::ExecuteHooksWorker)
+ .to receive(:perform_async).with(deployment.id)
+
+ deployment.drop!
+ end
end
context 'when deployment was canceled' do
@@ -169,12 +196,19 @@ RSpec.describe Deployment do
end
end
- it 'executes Deployments::FinishedWorker asynchronously' do
- expect(Deployments::FinishedWorker)
+ it 'executes Deployments::LinkMergeRequestWorker asynchronously' do
+ expect(Deployments::LinkMergeRequestWorker)
.to receive(:perform_async).with(deployment.id)
deployment.cancel!
end
+
+ it 'executes Deployments::ExecuteHooksWorker asynchronously' do
+ expect(Deployments::ExecuteHooksWorker)
+ .to receive(:perform_async).with(deployment.id)
+
+ deployment.cancel!
+ end
end
end
@@ -580,9 +614,10 @@ RSpec.describe Deployment do
expect(deploy).to be_success
end
- it 'schedules SuccessWorker and FinishedWorker when finishing a deploy' do
- expect(Deployments::SuccessWorker).to receive(:perform_async)
- expect(Deployments::FinishedWorker).to receive(:perform_async)
+ it 'schedules workers when finishing a deploy' do
+ expect(Deployments::UpdateEnvironmentWorker).to receive(:perform_async)
+ expect(Deployments::LinkMergeRequestWorker).to receive(:perform_async)
+ expect(Deployments::ExecuteHooksWorker).to receive(:perform_async)
deploy.update_status('success')
end