summaryrefslogtreecommitdiff
path: root/spec/factories/labels.rb
blob: 81d3e4be6fd4bcb78b6b6a61e35a6ff1cff8e490 (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
# frozen_string_literal: true

FactoryBot.define do
  trait :base_label do
    title { generate(:label_title) }
    color { "#990000" }
  end

  factory :label, traits: [:base_label], class: 'ProjectLabel' do
    project

    transient do
      priority { nil }
    end

    after(:create) do |label, evaluator|
      if evaluator.priority
        label.priorities.create(project: label.project, priority: evaluator.priority)
      end
    end
  end

  factory :group_label, traits: [:base_label] do
    group
  end
end