summaryrefslogtreecommitdiff
path: root/spec/models/environment_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-31 21:06:28 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-31 21:06:28 +0000
commit8f210aebe1d740e8ee194f171f1f33a6e1fba313 (patch)
treef43c545801bb96fd0737f18493fb30ab92972627 /spec/models/environment_spec.rb
parent996f700997805b3590da8d8afdd19d193989078a (diff)
downloadgitlab-ce-8f210aebe1d740e8ee194f171f1f33a6e1fba313.tar.gz
Add latest changes from gitlab-org/gitlab@master
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? }