|
|
|
|
@ -58,7 +58,6 @@ RSpec.describe LocationsHelper do
|
|
|
|
|
Timecop.unfreeze |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there have not been any previous deactivations" do |
|
|
|
|
it "returns one active period without to date" do |
|
|
|
|
expect(active_periods(location).count).to eq(1) |
|
|
|
|
expect(active_periods(location).first).to have_attributes(from: Time.zone.local(2022, 4, 1), to: nil) |
|
|
|
|
@ -121,6 +120,14 @@ RSpec.describe LocationsHelper do
|
|
|
|
|
expect(active_periods(location).first).to have_attributes(from: Time.zone.local(2022, 4, 1), to: Time.zone.local(2022, 4, 6)) |
|
|
|
|
expect(active_periods(location).second).to have_attributes(from: Time.zone.local(2022, 11, 11), to: nil) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns correct active periods when a full deactivation period happens during another deactivation period" do |
|
|
|
|
location.location_deactivation_periods << FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 5, 5), reactivation_date: Time.zone.local(2022, 6, 11)) |
|
|
|
|
location.location_deactivation_periods << FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 4, 6), reactivation_date: Time.zone.local(2022, 7, 7)) |
|
|
|
|
|
|
|
|
|
expect(active_periods(location).count).to eq(2) |
|
|
|
|
expect(active_periods(location).first).to have_attributes(from: Time.zone.local(2022, 4, 1), to: Time.zone.local(2022, 4, 6)) |
|
|
|
|
expect(active_periods(location).second).to have_attributes(from: Time.zone.local(2022, 7, 7), to: nil) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|