Browse Source

CLDC-1860 Change location question header for 23/24 (#1291)

* Change location question header for 23/24

* Stup form in page tests
pull/1337/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
66a528bd48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      app/models/form/lettings/questions/location_id.rb
  2. 6
      spec/models/form/lettings/pages/location_spec.rb
  3. 18
      spec/models/form/lettings/questions/location_id_spec.rb

10
app/models/form/lettings/questions/location_id.rb

@ -2,7 +2,7 @@ class Form::Lettings::Questions::LocationId < ::Form::Question
def initialize(_id, hsh, page) def initialize(_id, hsh, page)
super("location_id", hsh, page) super("location_id", hsh, page)
@check_answer_label = "Location" @check_answer_label = "Location"
@header = "Which location is this log for?" @header = header_text
@type = "radio" @type = "radio"
@answer_options = answer_options @answer_options = answer_options
@inferred_answers = { @inferred_answers = {
@ -47,4 +47,12 @@ private
def selected_answer_option_is_derived?(_lettings_log) def selected_answer_option_is_derived?(_lettings_log)
false false
end end
def header_text
if form.start_date && form.start_date.year >= 2023
"Which location is this letting for?"
else
"Which location is this log for?"
end
end
end end

6
spec/models/form/lettings/pages/location_spec.rb

@ -6,6 +6,12 @@ RSpec.describe Form::Lettings::Pages::Location, type: :model do
let(:page_id) { nil } let(:page_id) { nil }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form) }
before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2022, 4, 1))
allow(subsection).to receive(:form).and_return(form)
end
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)

18
spec/models/form/lettings/questions/location_id_spec.rb

@ -6,6 +6,14 @@ RSpec.describe Form::Lettings::Questions::LocationId, type: :model do
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form) }
before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2022, 4, 1))
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
it "has correct page" do it "has correct page" do
expect(question.page).to eq(page) expect(question.page).to eq(page)
@ -103,4 +111,14 @@ RSpec.describe Form::Lettings::Questions::LocationId, type: :model do
end end
end end
end end
context "with collection year on or after 2023" do
before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2023, 4, 1))
end
it "has the correct header" do
expect(question.header).to eq("Which location is this letting for?")
end
end
end end

Loading…
Cancel
Save