summaryrefslogtreecommitdiff
path: root/spec/models/deployment_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/models/deployment_spec.rb
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
downloadgitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/models/deployment_spec.rb')
-rw-r--r--spec/models/deployment_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb
index 47c246d12cc..705b9b4cc65 100644
--- a/spec/models/deployment_spec.rb
+++ b/spec/models/deployment_spec.rb
@@ -524,6 +524,16 @@ RSpec.describe Deployment do
is_expected.to contain_exactly(deployment1, deployment2, deployment3, deployment4, deployment5)
end
+
+ it 'has a corresponding database index' do
+ index = ApplicationRecord.connection.indexes('deployments').find do |i|
+ i.name == 'index_deployments_for_visible_scope'
+ end
+
+ scope_values = described_class::VISIBLE_STATUSES.map { |s| described_class.statuses[s] }.to_s
+
+ expect(index.where).to include(scope_values)
+ end
end
describe 'upcoming' do
@@ -1055,6 +1065,40 @@ RSpec.describe Deployment do
end
end
+ describe '#tier_in_yaml' do
+ context 'when deployable is nil' do
+ before do
+ subject.deployable = nil
+ end
+
+ it 'returns nil' do
+ expect(subject.tier_in_yaml).to be_nil
+ end
+ end
+
+ context 'when deployable is present' do
+ context 'when tier is specified' do
+ let(:deployable) { create(:ci_build, :success, :environment_with_deployment_tier) }
+
+ before do
+ subject.deployable = deployable
+ end
+
+ it 'returns the tier' do
+ expect(subject.tier_in_yaml).to eq('testing')
+ end
+
+ context 'when tier is not specified' do
+ let(:deployable) { create(:ci_build, :success) }
+
+ it 'returns nil' do
+ expect(subject.tier_in_yaml).to be_nil
+ end
+ end
+ end
+ end
+ end
+
describe '.fast_destroy_all' do
it 'cleans path_refs for destroyed environments' do
project = create(:project, :repository)