summaryrefslogtreecommitdiff
path: root/spec/models/ci
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-06-01 19:07:57 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-06-01 19:07:57 +0800
commit66edbc5e5cfe49984069512a9e550df9498497d8 (patch)
treebc50df38a245fdecda494a7398c78a40e087a3ab /spec/models/ci
parent4f8a1c0d4cc9372823cb28a16936c49dd4f09402 (diff)
downloadgitlab-ce-66edbc5e5cfe49984069512a9e550df9498497d8.tar.gz
Introduce ci_environment_url which would fallback
to the external_url from persisted environment, and make the other utility methods private as we don't really need to use them outside of the job.
Diffstat (limited to 'spec/models/ci')
-rw-r--r--spec/models/ci/build_spec.rb24
1 files changed, 18 insertions, 6 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 141a2741ced..0c68ac20c7d 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -427,11 +427,11 @@ describe Ci::Build, :models do
end
end
- describe '#expanded_environment_url' do
- subject { build.expanded_environment_url }
+ describe '#ci_environment_url' do
+ subject { job.ci_environment_url }
- context 'when environment uses $CI_COMMIT_REF_NAME' do
- let(:build) do
+ context 'when yaml environment uses $CI_COMMIT_REF_NAME' do
+ let(:job) do
create(:ci_build,
ref: 'master',
options: { environment: { url: 'http://review/$CI_COMMIT_REF_NAME' } })
@@ -440,8 +440,8 @@ describe Ci::Build, :models do
it { is_expected.to eq('http://review/master') }
end
- context 'when environment uses yaml_variables containing symbol keys' do
- let(:build) do
+ context 'when yaml environment uses yaml_variables containing symbol keys' do
+ let(:job) do
create(:ci_build,
yaml_variables: [{ key: :APP_HOST, value: 'host' }],
options: { environment: { url: 'http://review/$APP_HOST' } })
@@ -449,6 +449,18 @@ describe Ci::Build, :models do
it { is_expected.to eq('http://review/host') }
end
+
+ 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)
+ end
+
+ it 'returns the external_url from persisted environment' do
+ is_expected.to eq(environment.external_url)
+ end
+ end
end
describe '#starts_environment?' do