diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-07-27 18:31:24 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-07-28 12:13:30 +0300 |
commit | b59abf5b4495f00767c574c46e0cfed569204a85 (patch) | |
tree | c35ee5a76139d1085e5c35bdf76725b05989601c /spec | |
parent | 34d2b8e702da63ea6d79cbfe498a5bfcb3938e11 (diff) |
Use let(:params) instead of def param
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/ci/pipeline_trigger_service_spec.rb | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/spec/services/ci/pipeline_trigger_service_spec.rb b/spec/services/ci/pipeline_trigger_service_spec.rb index af1c9f9f10a..9e60d04738c 100644 --- a/spec/services/ci/pipeline_trigger_service_spec.rb +++ b/spec/services/ci/pipeline_trigger_service_spec.rb @@ -9,19 +9,23 @@ describe Ci::PipelineTriggerService, services: true do describe '#execute' do let(:user) { create(:user) } + let(:trigger) { create(:ci_trigger, project: project, owner: user) } + let(:result) { described_class.new(project, user, params).execute } + + let(:params) do + { token: token, ref: ref, variables: variables } + end before do project.add_developer(user) end - let(:result) { described_class.new(project, user, params).execute } - let(:trigger) { create(:ci_trigger, project: project, owner: user) } - context 'when params have an existsed trigger token' do let(:token) { trigger.token } context 'when params have an existsed ref' do let(:ref) { 'master' } + let(:variables) {} it 'triggers a pipeline' do expect { result }.to change { Ci::Pipeline.count }.by(1) @@ -44,6 +48,7 @@ describe Ci::PipelineTriggerService, services: true do context 'when params have a non-existsed ref' do let(:ref) { 'invalid-ref' } + let(:variables) {} it 'does not trigger a pipeline' do expect { result }.not_to change { Ci::Pipeline.count } @@ -54,6 +59,8 @@ describe Ci::PipelineTriggerService, services: true do context 'when params have a non-existsed trigger token' do let(:token) { 'invalid-token' } + let(:ref) {} + let(:variables) {} it 'does not trigger a pipeline' do expect { result }.not_to change { Ci::Pipeline.count } @@ -61,10 +68,4 @@ describe Ci::PipelineTriggerService, services: true do end end end - - def params - { token: defined?(token) ? token : nil, - ref: defined?(ref) ? ref : nil, - variables: defined?(variables) ? variables : nil } - end end |