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/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)