pipelines.rb 1.2 KB
Newer Older
D
Douwe Maan 已提交
1
FactoryGirl.define do
2
  factory :ci_empty_pipeline, class: Ci::Pipeline do
3
    ref 'master'
D
Douwe Maan 已提交
4
    sha '97de212e80737a608d939f648d959671fb0a0142'
5
    status 'pending'
D
Douwe Maan 已提交
6

K
Kamil Trzcinski 已提交
7
    project factory: :empty_project
K
WIP  
Kamil Trzcinski 已提交
8

9
    factory :ci_pipeline_without_jobs do
10 11
      after(:build) do |pipeline|
        allow(pipeline).to receive(:ci_yaml_file) { YAML.dump({}) }
D
Douwe Maan 已提交
12 13 14
      end
    end

15
    factory :ci_pipeline_with_one_job do
16 17 18 19
      after(:build) do |pipeline|
        allow(pipeline).to receive(:ci_yaml_file) do
          YAML.dump({ rspec: { script: "ls" } })
        end
D
Douwe Maan 已提交
20 21 22
      end
    end

23
    factory :ci_pipeline do
24
      transient { config nil }
25 26

      after(:build) do |pipeline, evaluator|
27 28 29 30 31 32 33
        allow(pipeline).to receive(:ci_yaml_file) do
          if evaluator.config
            YAML.dump(evaluator.config)
          else
            File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
          end
        end
34 35 36 37

        # Populates pipeline with errors
        #
        pipeline.config_processor if evaluator.config
38
      end
39 40 41 42

      trait :invalid do
        config(rspec: nil)
      end
43 44 45 46 47 48 49 50

      trait :blocked do
        status :manual
      end

      trait :success do
        status :success
      end
51
    end
D
Douwe Maan 已提交
52 53
  end
end