BigW Consortium Gitlab

Commit db17e6ad by Lin Jen-Shin

split tests for expanded_environment_url

parent a0990ff3
......@@ -427,8 +427,8 @@ describe Ci::Build, :models do
end
end
describe '#ci_environment_url' do
subject { job.ci_environment_url }
describe '#expanded_environment_url' do
subject { job.expanded_environment_url }
context 'when yaml environment uses $CI_COMMIT_REF_NAME' do
let(:job) do
......@@ -453,10 +453,31 @@ describe Ci::Build, :models do
context 'when yaml environment does not have url' do
let(:job) { create(:ci_build, environment: 'staging') }
let!(:environment) do
create(:environment, project: job.project, name: job.environment)
it { is_expected.to be_nil }
end
end
describe '#ci_environment_url' do
subject { job.ci_environment_url }
let!(:environment) do
create(:environment, project: job.project, name: job.environment)
end
context 'when yaml environment has url' do
let(:job) do
create(:ci_build,
ref: 'master',
environment: 'staging',
options: { environment: { url: 'http://review/$CI_COMMIT_REF_NAME' } })
end
it { is_expected.to eq('http://review/master') }
end
context 'when yaml environment does not have url' do
let(:job) { create(:ci_build, environment: 'staging') }
it 'returns the external_url from persisted environment' do
is_expected.to eq(environment.external_url)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment