Browse Source

CLDC-2032 test log creation in crossover period (#1420)

* ensure that no form is added to the forms hash under the key "nil"

* add a test to ensure that the form handler does not add outdated forms to the forms hash with key nil

* remove unnecessary singleton reinitialisation

* remove a duplicated Timecop around block
pull/1471/head
Arthur Campbell 2 years ago committed by GitHub
parent
commit
9f3b2bba28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/form_handler.rb
  2. 11
      spec/models/form_handler_spec.rb

2
app/models/form_handler.rb

@ -47,7 +47,7 @@ class FormHandler
form = Form.new(form_path) form = Form.new(form_path)
form_to_set = form_name_from_start_year(form.start_date.year, "lettings") form_to_set = form_name_from_start_year(form.start_date.year, "lettings")
forms[form_to_set] = form if forms[form_to_set].blank? forms[form_to_set] = form if form_to_set && forms[form_to_set].blank?
end end
end end

11
spec/models/form_handler_spec.rb

@ -9,8 +9,6 @@ RSpec.describe FormHandler do
Singleton.__init__(described_class) Singleton.__init__(described_class)
example.run example.run
end end
Timecop.return
Singleton.__init__(described_class)
end end
context "when accessing a form in a different year" do context "when accessing a form in a different year" do
@ -35,6 +33,15 @@ RSpec.describe FormHandler do
expect(all_forms.count).to be >= 1 expect(all_forms.count).to be >= 1
expect(all_forms["current_sales"]).to be_a(Form) expect(all_forms["current_sales"]).to be_a(Form)
end end
context "when in 23/24 period or later" do
let(:now) { Time.utc(2023, 6, 7) }
it "does not load outdated forms" do
all_forms = form_handler.forms
expect(all_forms.keys).not_to include nil
end
end
end end
describe "Get specific form" do describe "Get specific form" do

Loading…
Cancel
Save