2015-08-26 01:42:46 +00:00
|
|
|
FactoryGirl.define do
|
2016-06-03 14:22:26 +00:00
|
|
|
factory :ci_empty_pipeline, class: Ci::Pipeline do
|
2017-05-24 13:13:51 +00:00
|
|
|
source :push
|
2016-08-11 13:22:35 +00:00
|
|
|
ref 'master'
|
2015-08-26 01:42:46 +00:00
|
|
|
sha '97de212e80737a608d939f648d959671fb0a0142'
|
2016-08-11 13:22:35 +00:00
|
|
|
status 'pending'
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-08-02 19:55:11 +00:00
|
|
|
project
|
2015-09-28 11:14:34 +00:00
|
|
|
|
2016-06-03 14:22:26 +00:00
|
|
|
factory :ci_pipeline_without_jobs do
|
2016-11-25 14:15:31 +00:00
|
|
|
after(:build) do |pipeline|
|
2017-05-31 13:43:19 +00:00
|
|
|
pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({}))
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-03 14:22:26 +00:00
|
|
|
factory :ci_pipeline_with_one_job do
|
2016-11-25 14:15:31 +00:00
|
|
|
after(:build) do |pipeline|
|
|
|
|
allow(pipeline).to receive(:ci_yaml_file) do
|
2017-05-31 13:43:19 +00:00
|
|
|
pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({ rspec: { script: "ls" } }))
|
2016-11-25 14:15:31 +00:00
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-19 20:51:07 +00:00
|
|
|
# Persist merge request head_pipeline_id
|
|
|
|
# on pipeline factories to avoid circular references
|
|
|
|
transient { head_pipeline_of nil }
|
|
|
|
|
|
|
|
after(:create) do |pipeline, evaluator|
|
|
|
|
merge_request = evaluator.head_pipeline_of
|
|
|
|
merge_request&.update(head_pipeline: pipeline)
|
|
|
|
end
|
|
|
|
|
2016-06-03 14:22:26 +00:00
|
|
|
factory :ci_pipeline do
|
2016-11-27 15:24:43 +00:00
|
|
|
transient { config nil }
|
2016-11-25 14:11:56 +00:00
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
2017-05-31 13:43:19 +00:00
|
|
|
if evaluator.config
|
|
|
|
pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump(evaluator.config))
|
2016-12-21 13:26:47 +00:00
|
|
|
|
2017-05-31 13:43:19 +00:00
|
|
|
# Populates pipeline with errors
|
|
|
|
pipeline.config_processor if evaluator.config
|
|
|
|
else
|
|
|
|
pipeline.instance_variable_set(:@ci_yaml_file, File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')))
|
|
|
|
end
|
2016-11-25 14:11:56 +00:00
|
|
|
end
|
2017-01-04 11:48:24 +00:00
|
|
|
|
|
|
|
trait :invalid do
|
|
|
|
config(rspec: nil)
|
|
|
|
end
|
2017-03-08 10:44:36 +00:00
|
|
|
|
|
|
|
trait :blocked do
|
|
|
|
status :manual
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :success do
|
|
|
|
status :success
|
|
|
|
end
|
2017-03-30 11:29:52 +00:00
|
|
|
|
|
|
|
trait :failed do
|
|
|
|
status :failed
|
|
|
|
end
|
2016-11-25 14:11:56 +00:00
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
end
|