diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-06-01 21:09:36 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-06-01 21:09:36 +0800 |
commit | db17e6ad8fe4e91f13fe9028a162236faad7f214 (patch) | |
tree | 3e79772097e58ebd6bd3ee908a20510861f5dfe8 /spec | |
parent | a0990ff356e05ba7321c9295f39955dfed66b7aa (diff) | |
download | gitlab-ce-db17e6ad8fe4e91f13fe9028a162236faad7f214.tar.gz |
split tests for expanded_environment_url
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/ci/build_spec.rb | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 0c68ac20c7d..5a5702e5e8d 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -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 |