gitlab-org--gitlab-foss/spec/factories/labels.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
789 B
Ruby
Raw Normal View History

# frozen_string_literal: true
FactoryBot.define do
trait :base_label do
title { generate(:label_title) }
color { "#990000" }
end
trait :described do
description { "Description of #{title}" }
end
trait :scoped do
transient do
prefix { 'scope' }
end
title { "#{prefix}::#{generate(:label_title)}" }
end
factory :label, traits: [:base_label], class: 'ProjectLabel' do
project
2016-10-14 19:06:26 -04:00
transient do
priority { nil }
2016-10-14 19:06:26 -04:00
end
after(:create) do |label, evaluator|
if evaluator.priority
label.priorities.create!(project: label.project, priority: evaluator.priority)
2016-10-14 19:06:26 -04:00
end
end
end
factory :group_label, traits: [:base_label] do
group
end
factory :admin_label, traits: [:base_label], class: 'Label'
end