File: commit_statuses.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (89 lines) | stat: -rw-r--r-- 1,996 bytes parent folder | download
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# frozen_string_literal: true

FactoryBot.define do
  factory :commit_status, class: 'CommitStatus' do
    name { 'default' }
    stage_idx { 0 }
    status { 'success' }
    description { 'commit status' }
    pipeline factory: :ci_pipeline
    started_at { 'Tue, 26 Jan 2016 08:21:42 +0100' }
    finished_at { 'Tue, 26 Jan 2016 08:23:42 +0100' }
    partition_id { pipeline&.partition_id }
    stage { 'test' }

    before(:create) do |commit_status, evaluator|
      next if commit_status.ci_stage

      ci_stage = commit_status.pipeline.stages.find_by(name: evaluator.stage)

      commit_status.ci_stage =
        # rubocop: disable RSpec/FactoryBot/StrategyInCallback -- we need to create ci_stages if there aren't any
        (ci_stage.presence || create(
          :ci_stage,
          pipeline: commit_status.pipeline,
          project: commit_status.project || evaluator.project,
          name: evaluator.stage,
          position: evaluator.stage_idx,
          status: 'created'
        ))
      # rubocop: enable RSpec/FactoryBot/StrategyInCallback
    end

    trait :success do
      status { 'success' }
    end

    trait :failed do
      status { 'failed' }
    end

    trait :canceling do
      status { 'canceling' }
    end

    trait :canceled do
      status { 'canceled' }
    end

    trait :skipped do
      status { 'skipped' }
    end

    trait :running do
      status { 'running' }
    end

    trait :waiting_for_callback do
      status { 'waiting_for_callback' }
    end

    trait :pending do
      status { 'pending' }
    end

    trait :waiting_for_resource do
      status { 'waiting_for_resource' }
    end

    trait :preparing do
      status { 'preparing' }
    end

    trait :created do
      status { 'created' }
    end

    trait :manual do
      status { 'manual' }
    end

    trait :scheduled do
      status { 'scheduled' }
    end

    after(:build) do |build, evaluator|
      build.project ||= build.pipeline.project
    end
  end
end