FactoryBot.define do
  factory :directory do
    association :project
    association :user
    
    name "Payrolls"
    category "Finance"

    trait :for_manager do
      permissions "Account Managers & Project Managers"
    end

    trait :for_account_manager do
      permissions "Account Managers Only"
    end

    trait :with_files do
      files { [Rack::Test::UploadedFile.new('spec/fixtures/files/location_photo.png', 'image/png')] }
    end

    file_names = ['location_photo.png', 'material_photo.png', 'person_photo.png']

    trait :many_files do
      files { 30.times.map { Rack::Test::UploadedFile.new("spec/fixtures/files/#{file_names.sample}", 'image/png') } }
    end
  end
end
