summaryrefslogtreecommitdiff
path: root/spec/factories/ci/commits.rb
blob: 70e3fa319c66bea6854bc2be458454ca77210949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# == Schema Information
#
# Table name: commits
#
#  id             :integer          not null, primary key
#  project_id     :integer
#  ref            :string(255)
#  sha            :string(255)
#  before_sha     :string(255)
#  push_data      :text
#  created_at     :datetime
#  updated_at     :datetime
#  tag            :boolean          default(FALSE)
#  yaml_errors    :text
#  committed_at   :datetime
#  gl_project_id  :integer
#

# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
  factory :ci_empty_commit, class: Ci::Commit do
    sha '97de212e80737a608d939f648d959671fb0a0142'

    gl_project factory: :empty_project

    factory :ci_commit_without_jobs do
      after(:build) do |commit|
        allow(commit).to receive(:ci_yaml_file) { YAML.dump({}) }
      end
    end

    factory :ci_commit_with_one_job do
      after(:build) do |commit|
        allow(commit).to receive(:ci_yaml_file) { YAML.dump({ rspec: { script: "ls" } }) }
      end
    end

    factory :ci_commit_with_two_jobs do
      after(:build) do |commit|
        allow(commit).to receive(:ci_yaml_file) { YAML.dump({ rspec: { script: "ls" }, spinach: { script: "ls" } }) }
      end
    end

    factory :ci_commit do
      after(:build) do |commit|
        allow(commit).to receive(:ci_yaml_file) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) }
      end
    end
  end
end