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:
Diffstat (limited to 'spec/services/environments/stop_service_spec.rb')
-rw-r--r--spec/services/environments/stop_service_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/services/environments/stop_service_spec.rb b/spec/services/environments/stop_service_spec.rb
index 362071c1c26..31e6ebadc64 100644
--- a/spec/services/environments/stop_service_spec.rb
+++ b/spec/services/environments/stop_service_spec.rb
@@ -198,6 +198,30 @@ RSpec.describe Environments::StopService do
expect(pipeline.environments_in_self_and_descendants.first).to be_stopped
end
+
+ context 'with environment related jobs ' do
+ let!(:environment) { create(:environment, :available, name: 'staging', project: project) }
+ let!(:prepare_staging_job) { create(:ci_build, :prepare_staging, pipeline: pipeline, project: project) }
+ let!(:stop_staging_job) { create(:ci_build, :stop_staging, :manual, pipeline: pipeline, project: project) }
+
+ it 'does not stop environments that was not started by the merge request' do
+ subject
+
+ expect(prepare_staging_job.persisted_environment.state).to eq('available')
+ end
+
+ context 'when fix_related_environments_for_merge_requests feature flag is disabled' do
+ before do
+ stub_feature_flags(fix_related_environments_for_merge_requests: false)
+ end
+
+ it 'stops unrelated environments too' do
+ subject
+
+ expect(prepare_staging_job.persisted_environment.state).to eq('stopped')
+ end
+ end
+ end
end
context 'when user is a reporter' do