summaryrefslogtreecommitdiff
path: root/spec/factories/todos.rb
blob: 97a1265c46a640bc16a63e7bafcbd9913cdd1a7e (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
51
52
53
54
55
56
57
58
59
60
61
# frozen_string_literal: true

FactoryBot.define do
  factory :todo do
    project
    author { project&.creator || user }
    user { project&.creator || user }
    target factory: :issue
    action { Todo::ASSIGNED }

    trait :assigned do
      action { Todo::ASSIGNED }
    end

    trait :review_requested do
      action { Todo::REVIEW_REQUESTED }
    end

    trait :mentioned do
      action { Todo::MENTIONED }
    end

    trait :directly_addressed do
      action { Todo::DIRECTLY_ADDRESSED }
    end

    trait :build_failed do
      action { Todo::BUILD_FAILED }
      target factory: :merge_request
    end

    trait :marked do
      action { Todo::MARKED }
    end

    trait :approval_required do
      action { Todo::APPROVAL_REQUIRED }
    end

    trait :unmergeable do
      action { Todo::UNMERGEABLE }
    end

    trait :pending do
      state { :pending }
    end

    trait :done do
      state { :done }
    end
  end

  factory :on_commit_todo, class: 'Todo' do
    project
    author
    user
    action { Todo::ASSIGNED }
    commit_id { RepoHelpers.sample_commit.id }
    target_type { "Commit" }
  end
end