issues.rb 679 Bytes
Newer Older
1
FactoryBot.define do
2
  factory :issue do
Rémy Coutable's avatar
Rémy Coutable committed
3
    title { generate(:title) }
4
    project
5
    author { project.creator }
6
    updated_by { author }
7

8 9 10 11
    trait :confidential do
      confidential true
    end

12 13 14 15
    trait :opened do
      state :opened
    end

Jacopo's avatar
Jacopo committed
16 17 18 19
    trait :locked do
      discussion_locked true
    end

20 21
    trait :closed do
      state :closed
Rémy Coutable's avatar
Rémy Coutable committed
22
      closed_at { Time.now }
23 24 25
    end

    factory :closed_issue, traits: [:closed]
26
    factory :reopened_issue, traits: [:opened]
27 28 29 30 31 32 33

    factory :labeled_issue do
      transient do
        labels []
      end

      after(:create) do |issue, evaluator|
Lin Jen-Shin's avatar
Lin Jen-Shin committed
34
        issue.update(labels: evaluator.labels)
35 36
      end
    end
37 38
  end
end