ensl.org/spec/factories/ban.rb
2020-03-17 03:03:02 +02:00

31 lines
620 B
Ruby
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

FactoryBot.define do
factory :ban do
ban_type { Ban::TYPE_SITE }
expiry { Time.now.utc.to_date + 1 }
# Hack because of the awkward way bans are created (requires user_name)
before(:create) do |ban|
if ban.user.nil?
user = create :user
ban.user_name = user.username
else
ban.user_name = ban.user.username
end
end
end
trait :mute do
ban_type { Ban::TYPE_MUTE }
end
trait :site do
ban_type { Ban::TYPE_SITE }
end
trait :gather do
ban_type { Ban::TYPE_GATHER }
end
trait :expired do
expiry { Date.yesterday - 1 }
end
end