|
|
|
|
@ -111,4 +111,36 @@ RSpec.describe Location, type: :model do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "status" do |
|
|
|
|
let(:location) { FactoryBot.build(:location) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
Timecop.freeze(2022, 6, 7) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns active if the location is not deactivated" do |
|
|
|
|
location.deactivation_date = nil |
|
|
|
|
location.save! |
|
|
|
|
expect(location.status).to eq(:active) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns deactivating soon if deactivation_date is in the future" do |
|
|
|
|
location.deactivation_date = Time.zone.local(2022, 8, 8) |
|
|
|
|
location.save! |
|
|
|
|
expect(location.status).to eq(:deactivating_soon) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns deactivated if deactivation_date is in the past" do |
|
|
|
|
location.deactivation_date = Time.zone.local(2022, 4, 8) |
|
|
|
|
location.save! |
|
|
|
|
expect(location.status).to eq(:deactivated) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns deactivated if deactivation_date is today" do |
|
|
|
|
location.deactivation_date = Time.zone.local(2022, 6, 7) |
|
|
|
|
location.save! |
|
|
|
|
expect(location.status).to eq(:deactivated) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|