Browse Source

If scheme is incomplete and deactivated treat is as deactivated (#2842)

pull/2853/head^2
kosiakkatrina 3 weeks ago committed by GitHub
parent
commit
3b8858f594
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/models/scheme.rb
  2. 7
      spec/models/scheme_spec.rb

2
app/models/scheme.rb

@ -329,9 +329,9 @@ class Scheme < ApplicationRecord
def status_at(date)
return :deleted if discarded_at.present?
return :incomplete unless confirmed && locations.confirmed.any?
return :deactivated if owning_organisation.status_at(date) == :deactivated || owning_organisation.status_at(date) == :merged ||
(open_deactivation&.deactivation_date.present? && date >= open_deactivation.deactivation_date)
return :incomplete unless confirmed && locations.confirmed.any?
return :deactivating_soon if open_deactivation&.deactivation_date.present? && date < open_deactivation.deactivation_date
return :reactivating_soon if last_deactivation_before(date)&.reactivation_date.present? && date < last_deactivation_before(date).reactivation_date
return :activating_soon if startdate.present? && date < startdate

7
spec/models/scheme_spec.rb

@ -390,6 +390,13 @@ RSpec.describe Scheme, type: :model do
scheme.startdate = Time.zone.today + 2.weeks
expect(scheme.status).to eq(:activating_soon)
end
it "returns deactivated if scheme is deactivated and incomplete" do
scheme.update!(support_type: nil, confirmed: nil)
FactoryBot.create(:scheme_deactivation_period, deactivation_date: Time.zone.yesterday, scheme:)
scheme.reload
expect(scheme.status).to eq(:deactivated)
end
end
context "when there have been previous deactivations" do

Loading…
Cancel
Save