FactoryBot.define do
  factory :tag do
    transient do
      name { nil }
    end

    category { :general }
    post_count { 0 }
    association :tag_name

    after(:build) do |tag, evaluator|
      tag.name = evaluator.name if evaluator.name.present?
    end

    trait :nico do
      category { :nico }
      transient do
        name { "nico:#{ SecureRandom.hex(4) }" }
      end
    end
  end
end
