Browse Source

Replace hardcoded date

pull/1392/head
Kat 3 years ago
parent
commit
b9a26c98d6
  1. 2
      app/models/form/lettings/questions/la.rb
  2. 2
      app/models/form/lettings/questions/prevloc.rb
  3. 4
      spec/models/form/lettings/questions/la_spec.rb
  4. 4
      spec/models/form/lettings/questions/prevloc_spec.rb

2
app/models/form/lettings/questions/la.rb

@ -10,6 +10,6 @@ class Form::Lettings::Questions::La < ::Form::Question
end
def answer_options
{ "" => "Select an option" }.merge(LocalAuthority.active(Time.zone.local(2023, 4, 1)).england.map { |la| [la.code, la.name] }.to_h)
{ "" => "Select an option" }.merge(LocalAuthority.active(form.start_date).england.map { |la| [la.code, la.name] }.to_h)
end
end

2
app/models/form/lettings/questions/prevloc.rb

@ -11,6 +11,6 @@ class Form::Lettings::Questions::Prevloc < ::Form::Question
end
def answer_options
{ "" => "Select an option" }.merge(LocalAuthority.active(Time.zone.local(2023, 4, 1)).map { |la| [la.code, la.name] }.to_h)
{ "" => "Select an option" }.merge(LocalAuthority.active(form.start_date).map { |la| [la.code, la.name] }.to_h)
end
end

4
spec/models/form/lettings/questions/la_spec.rb

@ -5,7 +5,9 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
let(:page) { instance_double(Form::Page, subsection:) }
let(:start_date) { Time.utc(2023, 4, 1) }
it "has the correct answer_options" do
Rails.application.load_seed

4
spec/models/form/lettings/questions/prevloc_spec.rb

@ -5,8 +5,8 @@ RSpec.describe Form::Lettings::Questions::Prevloc, type: :model do
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
let(:page) { instance_double(Form::Page, subsection:) }
let(:start_date) { Time.utc(2023, 4, 1) }
it "has the correct answer_options" do

Loading…
Cancel
Save