2015-08-25 21:42:46 -04:00
|
|
|
FactoryGirl.define do
|
2016-06-03 10:22:26 -04:00
|
|
|
factory :ci_empty_pipeline, class: Ci::Pipeline do
|
2017-05-24 09:13:51 -04:00
|
|
|
source :push
|
2016-08-11 09:22:35 -04:00
|
|
|
ref 'master'
|
2015-08-25 21:42:46 -04:00
|
|
|
sha '97de212e80737a608d939f648d959671fb0a0142'
|
2016-08-11 09:22:35 -04:00
|
|
|
status 'pending'
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2017-08-02 15:55:11 -04:00
|
|
|
project
|
2015-09-28 07:14:34 -04:00
|
|
|
|
2016-06-03 10:22:26 -04:00
|
|
|
factory :ci_pipeline_without_jobs do
|
2016-11-25 09:15:31 -05:00
|
|
|
after(:build) do |pipeline|
|
2017-05-31 09:43:19 -04:00
|
|
|
pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({}))
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-03 10:22:26 -04:00
|
|
|
factory :ci_pipeline_with_one_job do
|
2016-11-25 09:15:31 -05:00
|
|
|
after(:build) do |pipeline|
|
|
|
|
allow(pipeline).to receive(:ci_yaml_file) do
|
2017-05-31 09:43:19 -04:00
|
|
|
pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({ rspec: { script: "ls" } }))
|
2016-11-25 09:15:31 -05:00
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-19 16:51:07 -04: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 10:22:26 -04:00
|
|
|
factory :ci_pipeline do
|
2016-11-27 10:24:43 -05:00
|
|
|
transient { config nil }
|
2016-11-25 09:11:56 -05:00
|
|
|
|
|
|
|
after(:build) do |pipeline, evaluator|
|
2017-05-31 09:43:19 -04:00
|
|
|
if evaluator.config
|
|
|
|
pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump(evaluator.config))
|
2016-12-21 08:26:47 -05:00
|
|
|
|
2017-05-31 09:43:19 -04: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 09:11:56 -05:00
|
|
|
end
|
2017-01-04 06:48:24 -05:00
|
|
|
|
|
|
|
trait :invalid do
|
|
|
|
config(rspec: nil)
|
|
|
|
end
|
2017-03-08 05:44:36 -05:00
|
|
|
|
|
|
|
trait :blocked do
|
|
|
|
status :manual
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :success do
|
|
|
|
status :success
|
|
|
|
end
|
2017-03-30 07:29:52 -04:00
|
|
|
|
|
|
|
trait :failed do
|
|
|
|
status :failed
|
|
|
|
end
|
2016-11-25 09:11:56 -05:00
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
end
|