diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-06-21 14:53:19 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-06-21 14:53:19 +0300 |
commit | 0d3631acc16b5046ef295bf09204a565cb8580ea (patch) | |
tree | 4492fb3fce752c172a8e2758c56572e5b46a5be4 /spec/services/create_deployment_service_spec.rb | |
parent | df095d7df66aad3e51df5bd07ecdd4758391ced4 (diff) |
Move expanded_environment_url to CreateDeploymentService
Because that's the only place we need it.
Diffstat (limited to 'spec/services/create_deployment_service_spec.rb')
-rw-r--r-- | spec/services/create_deployment_service_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/services/create_deployment_service_spec.rb b/spec/services/create_deployment_service_spec.rb index 6cf4342ad4c..790713cf2e4 100644 --- a/spec/services/create_deployment_service_spec.rb +++ b/spec/services/create_deployment_service_spec.rb @@ -122,6 +122,42 @@ describe CreateDeploymentService, services: true do end end + describe '#expanded_environment_url' do + subject { service.send(:expanded_environment_url) } + + 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' } }) + end + + it { is_expected.to eq('http://review/master') } + end + + 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' } }) + end + + 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 'processing of builds' do shared_examples 'does not create deployment' do it 'does not create a new deployment' do |