Commit cff104ec authored by Shinya Maeda's avatar Shinya Maeda

Fix spec

parent acc74978
......@@ -6,7 +6,7 @@ module Ci
belongs_to :pipeline, foreign_key: :commit_id
has_many :builds
# Ws swtiched to Ci::PipelineVariable from Ci::TriggerRequest.variables.
# We switched to Ci::PipelineVariable from Ci::TriggerRequest.variables.
# Ci::TriggerRequest doesn't save variables anymore.
validates :variables, absence: true
......
......@@ -34,9 +34,10 @@ module API
pipeline = result[:pipeline]
trigger_request = pipeline.trigger_request
# Ws swtiched to Ci::PipelineVariable from Ci::TriggerRequest.variables.
# We switched to Ci::PipelineVariable from Ci::TriggerRequest.variables.
# Ci::TriggerRequest doesn't save variables anymore.
# Although, to prevent braking compatibility, copying variables and present it as Ci::TriggerRequest.
# Here is copying Ci::PipelineVariable to Ci::TriggerRequest.variables for presenting the variables.
# The same endpoint in v4 API pressents Pipeline instead of TriggerRequest, so it doesn't need such a process.
pipeline.variables.each do |variable|
trigger_request.variables << { key: variable.key, value: variable.value }
end
......
......@@ -107,7 +107,7 @@ FactoryGirl.define do
end
trait :triggered do
trigger_request factory: :ci_trigger_request_with_variables # TODO:
trigger_request factory: :ci_trigger_request_with_variables
end
after(:build) do |build, evaluator|
......
......@@ -2,12 +2,11 @@ FactoryGirl.define do
factory :ci_trigger_request, class: Ci::TriggerRequest do
trigger factory: :ci_trigger
# We switched to Ci::PipelineVariable from Ci::TriggerRequest.variables.
# Ci::TriggerRequest doesn't save variables anymore, whereas old trigger requests still persist variables.
factory :ci_trigger_request_with_variables do
variables do
{
TRIGGER_KEY_1: 'TRIGGER_VALUE_1',
TRIGGER_KEY_2: 'TRIGGER_VALUE_2'
}
after(:create) do |trigger_request, evaluator|
trigger_request.update_attribute(:variables, { TRIGGER_KEY_1: 'TRIGGER_VALUE_1', TRIGGER_KEY_2: 'TRIGGER_VALUE_2' } )
end
end
end
......
......@@ -292,7 +292,7 @@ feature 'Jobs' do
end
feature 'Variables' do
let(:trigger_request) { create(:ci_trigger_request_with_variables) } # TODO:
let(:trigger_request) { create(:ci_trigger_request_with_variables) }
let(:job) do
create :ci_build, pipeline: pipeline, trigger_request: trigger_request
......
......@@ -1492,7 +1492,7 @@ describe Ci::Build do
context 'when build is for triggers' do
let(:trigger) { create(:ci_trigger, project: project) }
let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: pipeline, trigger: trigger) } # TODO:
let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: pipeline, trigger: trigger) }
let(:user_trigger_variable) do
{ key: :TRIGGER_KEY_1, value: 'TRIGGER_VALUE_1', public: false }
end
......
......@@ -559,7 +559,7 @@ describe API::Runner do
before do
trigger = create(:ci_trigger, project: project)
create(:ci_trigger_request_with_variables, pipeline: pipeline, builds: [job], trigger: trigger) # TODO:
create(:ci_trigger_request_with_variables, pipeline: pipeline, builds: [job], trigger: trigger)
project.variables << Ci::Variable.new(key: 'SECRET_KEY', value: 'secret_value')
end
......
......@@ -197,7 +197,7 @@ describe 'projects/jobs/show' do
end
describe 'shows trigger variables in sidebar' do
let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: pipeline) } # TODO:
let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: pipeline) }
before do
build.trigger_request = trigger_request
......
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