pipelines.rb 1.0 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
K
Kamil Trzcinski 已提交
10
      after(:build) do |commit|
11
        allow(commit).to receive(:ci_yaml_file) { YAML.dump({}) }
D
Douwe Maan 已提交
12 13 14
      end
    end

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

21
    factory :ci_pipeline do
K
Kamil Trzcinski 已提交
22 23
      after(:build) do |commit|
        allow(commit).to receive(:ci_yaml_file) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) }
D
Douwe Maan 已提交
24 25
      end
    end
26 27 28 29 30 31 32 33 34 35 36

    factory(:ci_pipeline_with_yaml) do
      transient { yaml nil }

      after(:build) do |pipeline, evaluator|
        raise ArgumentError unless evaluator.yaml

        allow(pipeline).to receive(:ci_yaml_file)
          .and_return(YAML.dump(evaluator.yaml))
      end
    end
D
Douwe Maan 已提交
37 38
  end
end