diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-09-04 22:21:47 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-09-04 22:21:47 +0900 |
commit | 5b88bd81f52b454c80c54bef9951bdb8cf607238 (patch) | |
tree | c2258ceecd95eb391b2d54715b49b310cefb5ef5 /spec | |
parent | fa6b9acaf9759c58353f8407ff20a7d02b8edf92 (diff) | |
download | gitlab-ce-5b88bd81f52b454c80c54bef9951bdb8cf607238.tar.gz |
Move trigger_variables to presenter
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/ci/build_spec.rb | 38 | ||||
-rw-r--r-- | spec/presenters/ci/build_presenter_spec.rb | 34 |
2 files changed, 34 insertions, 38 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 137c460cce8..08d22f166e4 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1690,44 +1690,6 @@ describe Ci::Build do end end - describe '#trigger_variables' do - let(:build) { create(:ci_build, pipeline: pipeline, trigger_request: trigger_request) } - let(:trigger) { create(:ci_trigger, project: project) } - let(:trigger_request) { create(:ci_trigger_request, pipeline: pipeline, trigger: trigger) } - - subject { build.trigger_variables } - - it { is_expected.to eq(true) } - - context 'when variable is stored in ci_pipeline_variables' do - let!(:pipeline_variable) { create(:ci_pipeline_variable, pipeline: pipeline) } - - context 'when pipeline is triggered by trigger API' do - it 'returns variables' do - is_expected.to eq([pipeline_variable.to_runner_variable]) - end - end - - context 'when pipeline is not triggered by trigger API' do - let(:build) { create(:ci_build, pipeline: pipeline) } - - it 'does not return variables' do - is_expected.to eq([]) - end - end - end - - context 'when variable is stored in ci_trigger_requests.variables' do - before do - trigger_request.update_attribute(:variables, { 'TRIGGER_KEY_1' => 'TRIGGER_VALUE_1' } ) - end - - it 'returns variables' do - is_expected.to eq(trigger_request.user_variables) - end - end - end - describe 'state transition: any => [:pending]' do let(:build) { create(:ci_build, :created) } diff --git a/spec/presenters/ci/build_presenter_spec.rb b/spec/presenters/ci/build_presenter_spec.rb index a7a34ecac72..1a8001be6ab 100644 --- a/spec/presenters/ci/build_presenter_spec.rb +++ b/spec/presenters/ci/build_presenter_spec.rb @@ -100,4 +100,38 @@ describe Ci::BuildPresenter do end end end + + describe '#trigger_variables' do + let(:build) { create(:ci_build, pipeline: pipeline, trigger_request: trigger_request) } + let(:trigger) { create(:ci_trigger, project: project) } + let(:trigger_request) { create(:ci_trigger_request, pipeline: pipeline, trigger: trigger) } + + context 'when variable is stored in ci_pipeline_variables' do + let!(:pipeline_variable) { create(:ci_pipeline_variable, pipeline: pipeline) } + + context 'when pipeline is triggered by trigger API' do + it 'returns variables' do + expect(presenter.trigger_variables).to eq([pipeline_variable.to_runner_variable]) + end + end + + context 'when pipeline is not triggered by trigger API' do + let(:build) { create(:ci_build, pipeline: pipeline) } + + it 'does not return variables' do + expect(presenter.trigger_variables).to eq([]) + end + end + end + + context 'when variable is stored in ci_trigger_requests.variables' do + before do + trigger_request.update_attribute(:variables, { 'TRIGGER_KEY_1' => 'TRIGGER_VALUE_1' } ) + end + + it 'returns variables' do + expect(presenter.trigger_variables).to eq(trigger_request.user_variables) + end + end + end end |