2024-07-31 13:35:35 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2024-03-23 15:29:55 -04:00
|
|
|
FactoryBot.define do
|
|
|
|
|
factory :stat do
|
|
|
|
|
year { 1 }
|
|
|
|
|
month { 1 }
|
2025-07-08 13:23:08 -04:00
|
|
|
distance { 1000 } # 1 km
|
2024-08-20 14:14:17 -04:00
|
|
|
user
|
2025-09-12 14:44:53 -04:00
|
|
|
sharing_settings { {} }
|
|
|
|
|
sharing_uuid { SecureRandom.uuid }
|
2024-07-31 13:35:35 -04:00
|
|
|
toponyms do
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
'cities' => [
|
|
|
|
|
{ 'city' => 'Moscow', 'points' => 7, 'timestamp' => 1_554_317_696, 'stayed_for' => 1831 }
|
|
|
|
|
],
|
|
|
|
|
'country' => 'Russia'
|
|
|
|
|
}, { 'cities' => [], 'country' => nil }
|
|
|
|
|
]
|
|
|
|
|
end
|
2025-09-12 14:44:53 -04:00
|
|
|
|
|
|
|
|
trait :with_sharing_enabled do
|
2025-09-12 15:38:25 -04:00
|
|
|
after(:create) do |stat, _evaluator|
|
2025-09-19 17:49:32 -04:00
|
|
|
stat.enable_sharing!(expiration: '24h')
|
2025-09-12 14:44:53 -04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
trait :with_sharing_disabled do
|
|
|
|
|
sharing_settings do
|
|
|
|
|
{
|
|
|
|
|
'enabled' => false,
|
|
|
|
|
'expiration' => nil,
|
|
|
|
|
'expires_at' => nil
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
trait :with_sharing_expired do
|
|
|
|
|
sharing_settings do
|
|
|
|
|
{
|
|
|
|
|
'enabled' => true,
|
|
|
|
|
'expiration' => '1h',
|
|
|
|
|
'expires_at' => 1.hour.ago.iso8601
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
2024-03-23 15:29:55 -04:00
|
|
|
end
|
|
|
|
|
end
|