builds.rb 1.57 KB
Newer Older
Douwe Maan's avatar
Douwe Maan committed
1
FactoryGirl.define do
2
  factory :ci_build, class: Ci::Build do
Kamil Trzcinski's avatar
Kamil Trzcinski committed
3
    name 'test'
4 5
    ref 'master'
    tag false
6
    created_at 'Di 29. Okt 09:50:00 CET 2013'
Douwe Maan's avatar
Douwe Maan committed
7 8
    started_at 'Di 29. Okt 09:51:28 CET 2013'
    finished_at 'Di 29. Okt 09:53:28 CET 2013'
Kamil Trzcinski's avatar
Kamil Trzcinski committed
9
    commands 'ls -a'
Douwe Maan's avatar
Douwe Maan committed
10 11 12 13 14 15 16
    options do
      {
        image: "ruby:2.1",
        services: ["postgres"]
      }
    end

17 18
    commit factory: :ci_commit

19 20 21 22 23 24 25 26
    trait :success do
      status 'success'
    end

    trait :failed do
      status 'failed'
    end

27 28 29 30
    trait :canceled do
      status 'canceled'
    end

31 32 33 34 35 36 37 38 39 40 41 42
    trait :running do
      status 'running'
    end

    trait :pending do
      status 'pending'
    end

    trait :allowed_to_fail do
      allow_failure true
    end

43 44 45 46
    after(:build) do |build, evaluator|
      build.project = build.commit.project
    end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
47
    factory :ci_not_started_build do
Douwe Maan's avatar
Douwe Maan committed
48 49 50
      started_at nil
      finished_at nil
    end
51 52 53 54

    factory :ci_build_tag do
      tag true
    end
55

56 57 58 59
    factory :ci_build_with_coverage do
      coverage 99.9
    end

Kamil Trzcinski's avatar
Kamil Trzcinski committed
60
    trait :trace do
61
      after(:create) do |build, evaluator|
62 63
        build.trace = 'BUILD TRACE'
      end
64
    end
65 66 67 68

    trait :artifacts do
      after(:create) do |build, _|
        build.artifacts_file =
69 70
          fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts.zip'),
                             'application/zip')
71 72

        build.artifacts_metadata =
73
          fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'),
74
                             'application/x-gzip')
75

76 77 78
        build.save!
      end
    end
Douwe Maan's avatar
Douwe Maan committed
79 80
  end
end