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/support/shared_examples/ci/deployable_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/ci/deployable_shared_examples.rb56
1 files changed, 49 insertions, 7 deletions
diff --git a/spec/support/shared_examples/ci/deployable_shared_examples.rb b/spec/support/shared_examples/ci/deployable_shared_examples.rb
index b51a8fa20e2..4f43d38e604 100644
--- a/spec/support/shared_examples/ci/deployable_shared_examples.rb
+++ b/spec/support/shared_examples/ci/deployable_shared_examples.rb
@@ -96,7 +96,7 @@ RSpec.shared_examples 'a deployable job' do
ActiveRecord::QueryRecorder.new { subject }
end
- index_for_build = recorded.log.index { |l| l.include?("UPDATE #{Ci::Build.quoted_table_name}") }
+ index_for_build = recorded.log.index { |l| l.include?("UPDATE #{described_class.quoted_table_name}") }
index_for_deployment = recorded.log.index { |l| l.include?("UPDATE \"deployments\"") }
expect(index_for_build).to be < index_for_deployment
@@ -259,7 +259,7 @@ RSpec.shared_examples 'a deployable job' do
describe '#environment_tier_from_options' do
subject { job.environment_tier_from_options }
- let(:job) { Ci::Build.new(options: options) }
+ let(:job) { described_class.new(options: options) }
let(:options) { { environment: { deployment_tier: 'production' } } }
it { is_expected.to eq('production') }
@@ -276,7 +276,7 @@ RSpec.shared_examples 'a deployable job' do
let(:options) { { environment: { deployment_tier: 'production' } } }
let!(:environment) { create(:environment, name: 'production', tier: 'development', project: project) }
- let(:job) { Ci::Build.new(options: options, environment: 'production', project: project) }
+ let(:job) { described_class.new(options: options, environment: 'production', project: project) }
it { is_expected.to eq('production') }
@@ -295,6 +295,52 @@ RSpec.shared_examples 'a deployable job' do
end
end
+ describe '#environment_url' do
+ subject { job.environment_url }
+
+ let!(:job) { create(factory_type, :with_deployment, :deploy_to_production, pipeline: pipeline) }
+
+ it { is_expected.to eq('http://prd.example.com/$CI_JOB_NAME') }
+
+ context 'when options does not include url' do
+ before do
+ job.update!(options: { environment: { url: nil } })
+ job.persisted_environment.update!(external_url: 'http://prd.example.com/$CI_JOB_NAME')
+ end
+
+ it 'fetches from the persisted environment' do
+ expect_any_instance_of(::Environment) do |environment|
+ expect(environment).to receive(:external_url).once
+ end
+
+ is_expected.to eq('http://prd.example.com/$CI_JOB_NAME')
+ end
+
+ context 'when persisted environment is absent' do
+ before do
+ job.clear_memoization(:persisted_environment)
+ job.persisted_environment = nil
+ end
+
+ it { is_expected.to be_nil }
+ end
+ end
+ end
+
+ describe '#environment_slug' do
+ subject { job.environment_slug }
+
+ let!(:job) { create(factory_type, :with_deployment, :start_review_app, pipeline: pipeline) }
+
+ it { is_expected.to eq('review-master-8dyme2') }
+
+ context 'when persisted environment is absent' do
+ let!(:job) { create(factory_type, :start_review_app, pipeline: pipeline) }
+
+ it { is_expected.to be_nil }
+ end
+ end
+
describe 'environment' do
describe '#has_environment_keyword?' do
subject { job.has_environment_keyword? }
@@ -536,10 +582,6 @@ RSpec.shared_examples 'a deployable job' do
end
describe '#deployment_status' do
- before do
- allow_any_instance_of(Ci::Build).to receive(:create_deployment) # rubocop:disable RSpec/AnyInstanceOf
- end
-
context 'when job is a last deployment' do
let(:job) { create(factory_type, :success, environment: 'production', pipeline: pipeline) }
let(:environment) { create(:environment, name: 'production', project: job.project) }