Browse Source

test: make location incomplete status depend on location.confirmed

pull/987/head
Sam Seed 4 years ago
parent
commit
fb3e500fdd
  1. 2
      app/models/location.rb
  2. 27
      spec/models/location_spec.rb

2
app/models/location.rb

@ -384,7 +384,7 @@ class Location < ApplicationRecord
end
def status(date = Time.zone.now)
return :incomplete if [postcode, units, type_of_unit, mobility_type].any?(&:blank?)
return :incomplete unless confirmed
return :deactivated if open_deactivation&.deactivation_date.present? && date >= open_deactivation.deactivation_date
return :deactivating_soon if open_deactivation&.deactivation_date.present? && date < open_deactivation.deactivation_date
return :reactivating_soon if recent_deactivation&.reactivation_date.present? && date < recent_deactivation.reactivation_date

27
spec/models/location_spec.rb

@ -123,30 +123,9 @@ RSpec.describe Location, type: :model do
Timecop.unfreeze
end
context "when location is missing some mandatory information" do
it "returns incomplete when the postcode is missing" do
location.postcode = nil
expect(location.status).to eq(:incomplete)
location.postcode = ""
expect(location.status).to eq(:incomplete)
end
it "returns incomplete when the number of units is missing" do
location.units = nil
expect(location.status).to eq(:incomplete)
end
it "returns incomplete when the unit type is missing" do
location.type_of_unit = nil
expect(location.status).to eq(:incomplete)
location.type_of_unit = ""
expect(location.status).to eq(:incomplete)
end
it "returns incomplete when the mobility type is missing" do
location.mobility_type = nil
expect(location.status).to eq(:incomplete)
location.mobility_type = ""
context "when location is not confirmed" do
it "returns incomplete " do
location.confirmed = false
expect(location.status).to eq(:incomplete)
end
end

Loading…
Cancel
Save