summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-08-28 23:29:28 +0900
committerShinya Maeda <shinya@gitlab.com>2017-09-04 21:55:26 +0900
commitcff104ec4b0dd2c53ed907ab7ca423b7c587dee8 (patch)
treecbe9d1b41351f79a1370725ce13f2fdc4af30cd4
parentacc7497855167d4f6ba481422112645a1a04a885 (diff)
downloadgitlab-ce-cff104ec4b0dd2c53ed907ab7ca423b7c587dee8.tar.gz
Fix spec
-rw-r--r--app/models/ci/trigger_request.rb2
-rw-r--r--lib/api/v3/triggers.rb5
-rw-r--r--spec/factories/ci/builds.rb2
-rw-r--r--spec/factories/ci/trigger_requests.rb9
-rw-r--r--spec/features/projects/jobs_spec.rb2
-rw-r--r--spec/models/ci/build_spec.rb2
-rw-r--r--spec/requests/api/runner_spec.rb2
-rw-r--r--spec/views/projects/jobs/show.html.haml_spec.rb2
8 files changed, 13 insertions, 13 deletions
diff --git a/app/models/ci/trigger_request.rb b/app/models/ci/trigger_request.rb
index 4e274a57504..2c860598281 100644
--- a/app/models/ci/trigger_request.rb
+++ b/app/models/ci/trigger_request.rb
@@ -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
diff --git a/lib/api/v3/triggers.rb b/lib/api/v3/triggers.rb
index e1da96104a5..497ccbe20c6 100644
--- a/lib/api/v3/triggers.rb
+++ b/lib/api/v3/triggers.rb
@@ -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
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb
index 592df038aa3..25ec63de94a 100644
--- a/spec/factories/ci/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -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|
diff --git a/spec/factories/ci/trigger_requests.rb b/spec/factories/ci/trigger_requests.rb
index 10e0ab4fd3c..72dad8c418c 100644
--- a/spec/factories/ci/trigger_requests.rb
+++ b/spec/factories/ci/trigger_requests.rb
@@ -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
diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb
index 3f59a66403b..037ac00d39f 100644
--- a/spec/features/projects/jobs_spec.rb
+++ b/spec/features/projects/jobs_spec.rb
@@ -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
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index c0ac4816ae1..3fe3ec17d36 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -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
diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb
index d3b29426db1..993164aa8fe 100644
--- a/spec/requests/api/runner_spec.rb
+++ b/spec/requests/api/runner_spec.rb
@@ -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
diff --git a/spec/views/projects/jobs/show.html.haml_spec.rb b/spec/views/projects/jobs/show.html.haml_spec.rb
index 7405df1742e..117f48450e2 100644
--- a/spec/views/projects/jobs/show.html.haml_spec.rb
+++ b/spec/views/projects/jobs/show.html.haml_spec.rb
@@ -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