Commit cff104ec authored by Shinya Maeda's avatar Shinya Maeda

Fix spec

parent acc74978
...@@ -6,7 +6,7 @@ module Ci ...@@ -6,7 +6,7 @@ module Ci
belongs_to :pipeline, foreign_key: :commit_id belongs_to :pipeline, foreign_key: :commit_id
has_many :builds 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. # Ci::TriggerRequest doesn't save variables anymore.
validates :variables, absence: true validates :variables, absence: true
......
...@@ -34,9 +34,10 @@ module API ...@@ -34,9 +34,10 @@ module API
pipeline = result[:pipeline] pipeline = result[:pipeline]
trigger_request = pipeline.trigger_request 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. # 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| pipeline.variables.each do |variable|
trigger_request.variables << { key: variable.key, value: variable.value } trigger_request.variables << { key: variable.key, value: variable.value }
end end
......
...@@ -107,7 +107,7 @@ FactoryGirl.define do ...@@ -107,7 +107,7 @@ FactoryGirl.define do
end end
trait :triggered do trait :triggered do
trigger_request factory: :ci_trigger_request_with_variables # TODO: trigger_request factory: :ci_trigger_request_with_variables
end end
after(:build) do |build, evaluator| after(:build) do |build, evaluator|
......
...@@ -2,12 +2,11 @@ FactoryGirl.define do ...@@ -2,12 +2,11 @@ FactoryGirl.define do
factory :ci_trigger_request, class: Ci::TriggerRequest do factory :ci_trigger_request, class: Ci::TriggerRequest do
trigger factory: :ci_trigger 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 factory :ci_trigger_request_with_variables do
variables do after(:create) do |trigger_request, evaluator|
{ trigger_request.update_attribute(:variables, { TRIGGER_KEY_1: 'TRIGGER_VALUE_1', TRIGGER_KEY_2: 'TRIGGER_VALUE_2' } )
TRIGGER_KEY_1: 'TRIGGER_VALUE_1',
TRIGGER_KEY_2: 'TRIGGER_VALUE_2'
}
end end
end end
end end
......
...@@ -292,7 +292,7 @@ feature 'Jobs' do ...@@ -292,7 +292,7 @@ feature 'Jobs' do
end end
feature 'Variables' do 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 let(:job) do
create :ci_build, pipeline: pipeline, trigger_request: trigger_request create :ci_build, pipeline: pipeline, trigger_request: trigger_request
......
...@@ -1492,7 +1492,7 @@ describe Ci::Build do ...@@ -1492,7 +1492,7 @@ describe Ci::Build do
context 'when build is for triggers' do context 'when build is for triggers' do
let(:trigger) { create(:ci_trigger, project: project) } 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 let(:user_trigger_variable) do
{ key: :TRIGGER_KEY_1, value: 'TRIGGER_VALUE_1', public: false } { key: :TRIGGER_KEY_1, value: 'TRIGGER_VALUE_1', public: false }
end end
......
...@@ -559,7 +559,7 @@ describe API::Runner do ...@@ -559,7 +559,7 @@ describe API::Runner do
before do before do
trigger = create(:ci_trigger, project: project) 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') project.variables << Ci::Variable.new(key: 'SECRET_KEY', value: 'secret_value')
end end
......
...@@ -197,7 +197,7 @@ describe 'projects/jobs/show' do ...@@ -197,7 +197,7 @@ describe 'projects/jobs/show' do
end end
describe 'shows trigger variables in sidebar' do 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 before do
build.trigger_request = trigger_request 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