ensl.org/spec/factories/ban.rb

36 lines
868 B
Ruby
Raw Normal View History

FactoryBot.define do
factory :ban, class: Ban do
2020-03-17 01:03:02 +00:00
ban_type { Ban::TYPE_SITE }
2020-03-25 01:13:38 +00:00
# NOTE: due to time zone difference this causes tests to fail
# When adding the time, its in previous day and the time is set to 00:00
# read: http://danilenko.org/2012/7/6/rails_timezones/
expiry { Time.now.utc + 1.day }
2015-08-01 15:44:39 +00:00
# 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
2015-11-07 06:21:31 +00:00
else
2015-08-01 15:44:39 +00:00
ban.user_name = ban.user.username
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
2020-03-25 01:13:38 +00:00
expiry { Time.now.utc - 1.day }
end
2015-08-01 15:44:39 +00:00
end
2015-11-07 06:21:31 +00:00
end