2020-10-31 18:44:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe WorkingHour do
|
|
|
|
context 'when on monday 10am' do
|
|
|
|
before do
|
|
|
|
Time.zone = 'UTC'
|
|
|
|
create(:working_hour)
|
|
|
|
travel_to '26.10.2020 10:00'.to_datetime
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is considered working hour' do
|
|
|
|
expect(described_class.today.open_now?).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when on sunday 1pm' do
|
|
|
|
before do
|
|
|
|
Time.zone = 'UTC'
|
2021-03-13 06:14:28 +00:00
|
|
|
create(:working_hour, day_of_week: 0, closed_all_day: true)
|
2020-10-31 18:44:33 +00:00
|
|
|
travel_to '01.11.2020 13:00'.to_datetime
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is considered out of office' do
|
|
|
|
expect(described_class.today.closed_now?).to be true
|
|
|
|
end
|
|
|
|
end
|
2021-09-17 16:47:11 +00:00
|
|
|
|
|
|
|
context 'when on friday 12:30pm' do
|
|
|
|
before do
|
|
|
|
Time.zone = 'UTC'
|
|
|
|
create(:working_hour)
|
|
|
|
travel_to '10.09.2021 12:30'.to_datetime
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is considered to be in business hours' do
|
|
|
|
expect(described_class.today.open_now?).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when on friday 17:30pm' do
|
|
|
|
before do
|
|
|
|
Time.zone = 'UTC'
|
|
|
|
create(:working_hour)
|
|
|
|
travel_to '10.09.2021 17:30'.to_datetime
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is considered out of office' do
|
|
|
|
expect(described_class.today.closed_now?).to be true
|
|
|
|
end
|
|
|
|
end
|
2020-10-31 18:44:33 +00:00
|
|
|
end
|