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/models/environment_spec.rb')
-rw-r--r--spec/models/environment_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index c1f6302ee50..4566045bffd 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -515,6 +515,48 @@ describe Environment, :use_clean_rails_memory_store_caching do
end
end
+ describe '#last_visible_deployment' do
+ subject { environment.last_visible_deployment }
+
+ before do
+ allow_any_instance_of(Deployment).to receive(:create_ref)
+ end
+
+ context 'when there is an old deployment record' do
+ let!(:previous_deployment) { create(:deployment, :success, environment: environment) }
+
+ context 'when there is a deployment record with created status' do
+ let!(:deployment) { create(:deployment, environment: environment) }
+
+ it { is_expected.to eq(previous_deployment) }
+ end
+
+ context 'when there is a deployment record with running status' do
+ let!(:deployment) { create(:deployment, :running, environment: environment) }
+
+ it { is_expected.to eq(deployment) }
+ end
+
+ context 'when there is a deployment record with success status' do
+ let!(:deployment) { create(:deployment, :success, environment: environment) }
+
+ it { is_expected.to eq(deployment) }
+ end
+
+ context 'when there is a deployment record with failed status' do
+ let!(:deployment) { create(:deployment, :failed, environment: environment) }
+
+ it { is_expected.to eq(deployment) }
+ end
+
+ context 'when there is a deployment record with canceled status' do
+ let!(:deployment) { create(:deployment, :canceled, environment: environment) }
+
+ it { is_expected.to eq(deployment) }
+ end
+ end
+ end
+
describe '#has_terminals?' do
subject { environment.has_terminals? }