2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2018-08-29 19:50:58 +00:00
|
|
|
FactoryBot.define do
|
|
|
|
factory :calendar do
|
|
|
|
sequence(:name) { |n| "Escalation Test #{n}" }
|
2019-03-27 09:01:36 +00:00
|
|
|
timezone { 'Europe/Berlin' }
|
|
|
|
default { true }
|
|
|
|
ical_url { nil }
|
2021-02-15 13:55:00 +00:00
|
|
|
created_by_id { 1 }
|
|
|
|
updated_by_id { 1 }
|
2019-04-08 13:50:21 +00:00
|
|
|
|
2021-02-15 13:55:00 +00:00
|
|
|
transient do
|
|
|
|
public_holiday_date { nil }
|
2018-08-29 19:50:58 +00:00
|
|
|
end
|
2019-04-08 13:50:21 +00:00
|
|
|
|
2021-02-15 13:55:00 +00:00
|
|
|
public_holidays do
|
|
|
|
next if public_holiday_date.blank?
|
|
|
|
|
|
|
|
Array(public_holiday_date).each_with_object({}) do |elem, memo|
|
|
|
|
memo[elem.to_s] = { active: true, summary: 'public holiday trait' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
business_hours_9_17
|
|
|
|
|
|
|
|
trait :business_hours_9_17 do
|
|
|
|
business_hours do
|
|
|
|
{
|
|
|
|
mon: {
|
|
|
|
active: true,
|
|
|
|
timeframes: [['09:00', '17:00']]
|
|
|
|
},
|
|
|
|
tue: {
|
|
|
|
active: true,
|
|
|
|
timeframes: [['09:00', '17:00']]
|
|
|
|
},
|
|
|
|
wed: {
|
|
|
|
active: true,
|
|
|
|
timeframes: [['09:00', '17:00']]
|
|
|
|
},
|
|
|
|
thu: {
|
|
|
|
active: true,
|
|
|
|
timeframes: [['09:00', '17:00']]
|
|
|
|
},
|
|
|
|
fri: {
|
|
|
|
active: true,
|
|
|
|
timeframes: [['09:00', '17:00']]
|
|
|
|
},
|
|
|
|
sat: {
|
|
|
|
active: false,
|
|
|
|
timeframes: [['09:00', '17:00']]
|
|
|
|
},
|
|
|
|
sun: {
|
|
|
|
active: false,
|
|
|
|
timeframes: [['09:00', '17:00']]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2019-04-08 13:50:21 +00:00
|
|
|
|
|
|
|
trait :'24/7' do
|
|
|
|
business_hours do
|
|
|
|
{
|
|
|
|
mon: {
|
|
|
|
active: true,
|
2019-05-14 13:34:41 +00:00
|
|
|
timeframes: [ ['00:00', '24:00'] ]
|
2019-04-08 13:50:21 +00:00
|
|
|
},
|
|
|
|
tue: {
|
|
|
|
active: true,
|
2019-05-14 13:34:41 +00:00
|
|
|
timeframes: [ ['00:00', '24:00'] ]
|
2019-04-08 13:50:21 +00:00
|
|
|
},
|
|
|
|
wed: {
|
|
|
|
active: true,
|
2019-05-14 13:34:41 +00:00
|
|
|
timeframes: [ ['00:00', '24:00'] ]
|
2019-04-08 13:50:21 +00:00
|
|
|
},
|
|
|
|
thu: {
|
|
|
|
active: true,
|
2019-05-14 13:34:41 +00:00
|
|
|
timeframes: [ ['00:00', '24:00'] ]
|
2019-04-08 13:50:21 +00:00
|
|
|
},
|
|
|
|
fri: {
|
|
|
|
active: true,
|
2019-05-14 13:34:41 +00:00
|
|
|
timeframes: [ ['00:00', '24:00'] ]
|
2019-04-08 13:50:21 +00:00
|
|
|
},
|
|
|
|
sat: {
|
|
|
|
active: true,
|
2019-05-14 13:34:41 +00:00
|
|
|
timeframes: [ ['00:00', '24:00'] ]
|
2019-04-08 13:50:21 +00:00
|
|
|
},
|
|
|
|
sun: {
|
|
|
|
active: true,
|
2019-05-14 13:34:41 +00:00
|
|
|
timeframes: [ ['00:00', '24:00'] ]
|
2019-04-08 13:50:21 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2020-11-06 09:43:12 +00:00
|
|
|
|
|
|
|
trait '23:59/7' do
|
|
|
|
business_hours_generated
|
|
|
|
|
|
|
|
timeframe_alldays { ['00:00', '23:59'] }
|
|
|
|
end
|
|
|
|
|
2021-02-15 13:55:00 +00:00
|
|
|
trait :'9-18/7' do
|
|
|
|
business_hours_generated
|
|
|
|
|
|
|
|
timeframe_alldays { ['09:00', '18:00'] }
|
|
|
|
end
|
|
|
|
|
2020-11-06 09:43:12 +00:00
|
|
|
trait :business_hours_generated do
|
|
|
|
transient do
|
|
|
|
timeframe_alldays { nil }
|
|
|
|
timeframe_workdays { timeframe_alldays }
|
|
|
|
timeframe_weekends { timeframe_alldays }
|
|
|
|
config_workdays { timeframe_workdays ? { active: true, timeframes: [timeframe_workdays] } : {} }
|
|
|
|
config_weekends { timeframe_weekends ? { active: true, timeframes: [timeframe_weekends] } : {} }
|
|
|
|
end
|
|
|
|
|
|
|
|
business_hours do
|
|
|
|
hash = {}
|
|
|
|
%i[mon tue wed thu fri].each_with_object(hash) { |elem, memo| memo[elem] = config_workdays }
|
|
|
|
%i[sat sun].each_with_object(hash) { |elem, memo| memo[elem] = config_weekends }
|
|
|
|
hash
|
|
|
|
end
|
|
|
|
end
|
2018-08-29 19:50:58 +00:00
|
|
|
end
|
|
|
|
end
|