19
spec/models/concerns/out_of_offisable_spec.rb
Normal file
19
spec/models/concerns/out_of_offisable_spec.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
require 'rails_helper'
|
||||
|
||||
shared_examples_for 'out_of_offisable' do
|
||||
let(:obj) { create(described_class.to_s.underscore, working_hours_enabled: true, out_of_office_message: 'Message') }
|
||||
|
||||
it 'has after create callback' do
|
||||
expect(obj.working_hours.count).to eq(7)
|
||||
end
|
||||
|
||||
it 'is working on monday 10am' do
|
||||
travel_to '26.10.2020 10:00'.to_datetime
|
||||
expect(obj.working_now?).to be true
|
||||
end
|
||||
|
||||
it 'is out of office on sunday 1pm' do
|
||||
travel_to '01.11.2020 13:00'.to_datetime
|
||||
expect(obj.out_of_office?).to be true
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
require Rails.root.join 'spec/models/concerns/out_of_offisable_spec.rb'
|
||||
|
||||
RSpec.describe Inbox do
|
||||
describe 'validations' do
|
||||
@@ -33,6 +34,10 @@ RSpec.describe Inbox do
|
||||
it { is_expected.to have_many(:hooks) }
|
||||
end
|
||||
|
||||
describe 'concerns' do
|
||||
it_behaves_like 'out_of_offisable'
|
||||
end
|
||||
|
||||
describe '#add_member' do
|
||||
let(:inbox) { FactoryBot.create(:inbox) }
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
|
||||
29
spec/models/working_hour_spec.rb
Normal file
29
spec/models/working_hour_spec.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
# 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'
|
||||
create(:working_hour, day_of_week: 7, closed_all_day: true)
|
||||
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
|
||||
end
|
||||
Reference in New Issue
Block a user