BigW Consortium Gitlab

Commit b59abf5b by Shinya Maeda

Use let(:params) instead of def param

parent 34d2b8e7
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment