Browse Source

Set the scheme as available from previous year if the collection is in crossover

further-bulk-upload-year-fixes
Kat 2 years ago
parent
commit
3b0cc9879d
  1. 6
      app/models/scheme.rb
  2. 4
      spec/components/check_answers_summary_list_card_component_spec.rb
  3. 4
      spec/models/sales_log_spec.rb
  4. 2
      spec/models/validations/sales/setup_validations_spec.rb

6
app/models/scheme.rb

@ -219,7 +219,11 @@ class Scheme < ApplicationRecord
end end
def available_from def available_from
FormHandler.instance.collection_start_date(created_at) if FormHandler.instance.in_crossover_period?(now: created_at)
FormHandler.instance.collection_start_date(created_at) - 1.year
else
FormHandler.instance.collection_start_date(created_at)
end
end end
def open_deactivation def open_deactivation

4
spec/components/check_answers_summary_list_card_component_spec.rb

@ -10,11 +10,11 @@ RSpec.describe CheckAnswersSummaryListCardComponent, type: :component do
Timecop.freeze(Time.zone.local(2023, 1, 10)) Timecop.freeze(Time.zone.local(2023, 1, 10))
Singleton.__init__(FormHandler) Singleton.__init__(FormHandler)
end end
after do after do
Timecop.return Timecop.return
end end
context "when given a set of questions" do context "when given a set of questions" do
let(:user) { build(:user) } let(:user) { build(:user) }
let(:log) { build(:lettings_log, :completed, age2: 99, startdate: Time.zone.local(2021, 5, 1)) } let(:log) { build(:lettings_log, :completed, age2: 99, startdate: Time.zone.local(2021, 5, 1)) }

4
spec/models/sales_log_spec.rb

@ -95,11 +95,11 @@ RSpec.describe SalesLog, type: :model do
Timecop.freeze(Time.zone.local(2023, 1, 10)) Timecop.freeze(Time.zone.local(2023, 1, 10))
Singleton.__init__(FormHandler) Singleton.__init__(FormHandler)
end end
after do after do
Timecop.return Timecop.return
end end
it "has returns the correct form based on the start date" do it "has returns the correct form based on the start date" do
expect(sales_log.form_name).to be_nil expect(sales_log.form_name).to be_nil
expect(sales_log.form).to be_a(Form) expect(sales_log.form).to be_a(Form)

2
spec/models/validations/sales/setup_validations_spec.rb

@ -11,7 +11,7 @@ RSpec.describe Validations::Sales::SetupValidations do
Timecop.freeze(Time.zone.local(2023, 1, 10)) Timecop.freeze(Time.zone.local(2023, 1, 10))
Singleton.__init__(FormHandler) Singleton.__init__(FormHandler)
end end
after do after do
Timecop.return Timecop.return
end end

Loading…
Cancel
Save