Commit db17e6ad authored by Lin Jen-Shin's avatar Lin Jen-Shin

split tests for expanded_environment_url

parent a0990ff3
...@@ -427,8 +427,8 @@ describe Ci::Build, :models do ...@@ -427,8 +427,8 @@ describe Ci::Build, :models do
end end
end end
describe '#ci_environment_url' do describe '#expanded_environment_url' do
subject { job.ci_environment_url } subject { job.expanded_environment_url }
context 'when yaml environment uses $CI_COMMIT_REF_NAME' do context 'when yaml environment uses $CI_COMMIT_REF_NAME' do
let(:job) do let(:job) do
...@@ -453,10 +453,31 @@ describe Ci::Build, :models do ...@@ -453,10 +453,31 @@ describe Ci::Build, :models do
context 'when yaml environment does not have url' do context 'when yaml environment does not have url' do
let(:job) { create(:ci_build, environment: 'staging') } let(:job) { create(:ci_build, environment: 'staging') }
let!(:environment) do it { is_expected.to be_nil }
create(:environment, project: job.project, name: job.environment) 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 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 it 'returns the external_url from persisted environment' do
is_expected.to eq(environment.external_url) is_expected.to eq(environment.external_url)
end 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