Browse Source

Update edit_end_date

pull/1716/head
Kat 2 years ago
parent
commit
c339aac20d
  1. 5
      app/models/form.rb
  2. 2
      spec/models/form_spec.rb
  3. 2
      spec/models/validations/sales/setup_validations_spec.rb
  4. 2
      spec/models/validations/setup_validations_spec.rb

5
app/models/form.rb

@ -30,6 +30,7 @@ class Form
"sections" => sections,
}
@unresolved_log_redirect_page_id = "tenancy_start_date" if type == "lettings"
@edit_end_date = Time.zone.local(start_year + 1, 12, 31) # this is to be manually updated each year when we want to stop users from editing logs
else
raise "No form definition file exists for given year".freeze unless File.exist?(form_path)
@ -43,10 +44,10 @@ class Form
@questions = pages.flat_map(&:questions)
@start_date = Time.iso8601(form_definition["start_date"])
@new_logs_end_date = Time.iso8601(form_definition["end_date"])
@submission_deadline = Time.zone.local(2023, 6, 9)
@submission_deadline = Time.zone.local(@start_date.year + 1, 6, 9)
@edit_end_date = Time.zone.local(@start_date.year + 1, 12, 31)
@unresolved_log_redirect_page_id = form_definition["unresolved_log_redirect_page_id"]
end
@edit_end_date = @new_logs_end_date + 2.months # it depends on the year and QA activities, but it would always be later than new logs end date
@name = "#{start_date.year}_#{new_logs_end_date.year}_#{type}"
end

2
spec/models/form_spec.rb

@ -372,7 +372,7 @@ RSpec.describe Form, type: :model do
expect(form.questions.first.id).to eq("owning_organisation_id")
expect(form.start_date).to eq(Time.zone.parse("2022-04-01"))
expect(form.new_logs_end_date).to eq(Time.zone.parse("2023-08-07"))
expect(form.edit_end_date).to eq(Time.zone.parse("2023-10-07"))
expect(form.edit_end_date).to eq(Time.zone.parse("2023-12-31"))
expect(form.submission_deadline).to eq(Time.zone.parse("2023-06-09"))
expect(form.unresolved_log_redirect_page_id).to eq(nil)
end

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

@ -133,7 +133,7 @@ RSpec.describe Validations::Sales::SetupValidations do
let(:record) { build(:sales_log, saledate: Time.zone.local(2025, 4, 1)) }
before do
allow(Time).to receive(:now).and_return(Time.zone.local(2024, 12, 8))
allow(Time).to receive(:now).and_return(Time.zone.local(2025, 1, 8))
end
it "cannot create new logs for the previous collection year" do

2
spec/models/validations/setup_validations_spec.rb

@ -109,7 +109,7 @@ RSpec.describe Validations::SetupValidations do
context "when after the new logs end date and after the edit end date for the previous period" do
before do
allow(Time).to receive(:now).and_return(Time.zone.local(2023, 12, 8))
allow(Time).to receive(:now).and_return(Time.zone.local(2024, 1, 8))
end
it "cannot create new logs for the previous collection year" do

Loading…
Cancel
Save