Browse Source

Merge branch 'main' into CLDC-4202-update-question-numbers

# Conflicts:
#	app/models/form/lettings/questions/hhmemb.rb
CLDC-4202-update-question-numbers
Samuel Young 6 days ago
parent
commit
1be30765ee
  1. 4
      app/components/check_answers_summary_list_card_component.html.erb
  2. 5
      app/components/check_answers_summary_list_card_component.rb
  3. 1
      app/models/form/lettings/questions/hhmemb.rb
  4. 2
      app/models/form/question.rb
  5. 2
      config/locales/forms/2026/lettings/household_situation.en.yml
  6. 30
      spec/features/bulk_upload_sales_logs_spec.rb
  7. 32
      spec/models/form/lettings/pages/household_members_spec.rb
  8. 60
      spec/models/form/lettings/questions/hhmemb_spec.rb

4
app/components/check_answers_summary_list_card_component.html.erb

@ -1,8 +1,8 @@
<% if applicable_questions.first %> <% if applicable_questions.first %>
<div class="govuk-summary-card govuk-!-margin-bottom-6"> <div class="govuk-summary-card govuk-!-margin-bottom-6">
<% if applicable_questions.first.check_answers_card_number != 0 && applicable_questions.first.check_answers_card_number.present? %> <% if check_answers_card_label(applicable_questions.first).present? %>
<div class="govuk-summary-card__title-wrapper"> <div class="govuk-summary-card__title-wrapper">
<h3 class="govuk-summary-card__title"><%= check_answers_card_title(applicable_questions.first) %></h3> <h3 class="govuk-summary-card__title"><%= check_answers_card_label(applicable_questions.first) %></h3>
</div> </div>
<% end %> <% end %>

5
app/components/check_answers_summary_list_card_component.rb

@ -22,7 +22,10 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base
[question.question_number_string, question.check_answer_label.to_s.presence || question.header.to_s].compact.join(" - ") [question.question_number_string, question.check_answer_label.to_s.presence || question.header.to_s].compact.join(" - ")
end end
def check_answers_card_title(question) def check_answers_card_label(question)
return question.check_answers_card_title if question.check_answers_card_title.present?
return unless question.check_answers_card_number.present? && question.check_answers_card_number != 0
return "Lead tenant" if question.form.type == "lettings" && question.check_answers_card_number == 1 return "Lead tenant" if question.form.type == "lettings" && question.check_answers_card_number == 1
return "Buyer #{question.check_answers_card_number}" if question.check_answers_card_number <= number_of_buyers return "Buyer #{question.check_answers_card_number}" if question.check_answers_card_number <= number_of_buyers

1
app/models/form/lettings/questions/hhmemb.rb

@ -9,6 +9,7 @@ class Form::Lettings::Questions::Hhmemb < ::Form::Question
@min = 1 @min = 1
@step = 1 @step = 1
@question_number = get_question_number_from_hash(QUESTION_NUMBER_FROM_YEAR) @question_number = get_question_number_from_hash(QUESTION_NUMBER_FROM_YEAR)
@check_answers_card_title = "Household" if form.start_year_2026_or_later?
end end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 31, 2024 => 30, 2025 => 30, 2026 => 29 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 31, 2024 => 30, 2025 => 30, 2026 => 29 }.freeze

2
app/models/form/question.rb

@ -6,7 +6,7 @@ class Form::Question
:conditional_for, :readonly, :answer_options, :page, :conditional_for, :readonly, :answer_options, :page,
:inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value, :inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value,
:top_guidance_partial, :bottom_guidance_partial, :prefix, :suffix, :top_guidance_partial, :bottom_guidance_partial, :prefix, :suffix,
:requires_js, :fields_added, :derived, :check_answers_card_number, :requires_js, :fields_added, :derived, :check_answers_card_number, :check_answers_card_title,
:unresolved_hint_text, :question_number, :hide_question_number_on_page, :unresolved_hint_text, :question_number, :hide_question_number_on_page,
:plain_label, :error_label, :strip_commas :plain_label, :error_label, :strip_commas

2
config/locales/forms/2026/lettings/household_situation.en.yml

@ -35,7 +35,7 @@ en:
reason: reason:
check_answer_label: "Reason for leaving last settled home" check_answer_label: "Reason for leaving last settled home"
check_answer_prompt: "" check_answer_prompt: ""
hint_text: "The tenant’s ‘last settled home’ is their last long-standing home. For tenants who were in temporary accommodation, sleeping rough or otherwise homeless, their last settled home is where they were living previously." hint_text: "The tenant’s ‘last settled home’ is their last long-standing home. For tenants who were in temporary accommodation, sleeping rough or otherwise homeless, their last settled home is where they were living immediately before that period."
question_text: "What is the tenant’s main reason for the household leaving their last settled home?" question_text: "What is the tenant’s main reason for the household leaving their last settled home?"
reasonother: reasonother:
check_answer_label: "" check_answer_label: ""

30
spec/features/bulk_upload_sales_logs_spec.rb

@ -1,7 +1,10 @@
require "rails_helper" require "rails_helper"
RSpec.describe "Bulk upload sales log" do RSpec.describe "Bulk upload sales log" do
include CollectionTimeHelper
let(:user) { create(:user) } let(:user) { create(:user) }
let(:crossover_period) { nil }
let(:stub_file_upload) do let(:stub_file_upload) do
vcap_services = { "aws-s3-bucket" => {} } vcap_services = { "aws-s3-bucket" => {} }
@ -17,17 +20,12 @@ RSpec.describe "Bulk upload sales log" do
before do before do
stub_file_upload stub_file_upload
sign_in user sign_in user
allow(FormHandler.instance).to receive(:sales_in_crossover_period?).and_return(crossover_period)
end end
# rubocop:disable RSpec/AnyInstance # rubocop:disable RSpec/AnyInstance
context "when during crossover period" do context "when during crossover period" do
before do let(:crossover_period) { true }
Timecop.freeze(2024, 5, 1)
end
after do
Timecop.return
end
it "shows journey with year option" do it "shows journey with year option" do
visit("/sales-logs") visit("/sales-logs")
@ -38,15 +36,15 @@ RSpec.describe "Bulk upload sales log" do
click_button("Continue") click_button("Continue")
expect(page).to have_content("You must select a collection period to upload for") expect(page).to have_content("You must select a collection period to upload for")
choose("2024 to 2025") choose("#{current_collection_start_year} to #{current_collection_end_year}")
click_button("Continue") click_button("Continue")
click_link("Back") click_link("Back")
expect(page.find_field("form-year-2024-field")).to be_checked expect(page.find_field("form-year-#{current_collection_start_year}-field")).to be_checked
click_button("Continue") click_button("Continue")
expect(page).to have_content("Upload sales logs in bulk (2024 to 2025)") expect(page).to have_content("Upload sales logs in bulk (#{current_collection_start_year} to #{current_collection_end_year})")
click_button("Continue") click_button("Continue")
expect(page).to have_content("Upload your file") expect(page).to have_content("Upload your file")
@ -80,7 +78,7 @@ RSpec.describe "Bulk upload sales log" do
expect(page).to have_content("Which year") expect(page).to have_content("Which year")
click_button("Continue") click_button("Continue")
click_button("Continue") click_button("Continue")
choose("2024 to 2025") choose("#{current_collection_start_year} to #{current_collection_end_year}")
click_button("Continue") click_button("Continue")
click_button("Continue") click_button("Continue")
@ -95,20 +93,14 @@ RSpec.describe "Bulk upload sales log" do
# rubocop:enable RSpec/AnyInstance # rubocop:enable RSpec/AnyInstance
context "when not in crossover period" do context "when not in crossover period" do
before do let(:crossover_period) { false }
Timecop.freeze(2025, 2, 1)
end
after do
Timecop.return
end
it "shows journey without year option" do it "shows journey without year option" do
visit("/sales-logs") visit("/sales-logs")
expect(page).to have_link("Upload sales logs in bulk") expect(page).to have_link("Upload sales logs in bulk")
click_link("Upload sales logs in bulk") click_link("Upload sales logs in bulk")
expect(page).to have_content("Upload sales logs in bulk (2024 to 2025)") expect(page).to have_content("Upload sales logs in bulk (#{current_collection_start_year} to #{current_collection_end_year})")
click_button("Continue") click_button("Continue")
expect(page).to have_content("Upload your file") expect(page).to have_content("Upload your file")

32
spec/models/form/lettings/pages/household_members_spec.rb

@ -0,0 +1,32 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::HouseholdMembers, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: current_collection_start_date, start_year_2026_or_later?: true) }
before do
allow(subsection).to receive(:form).and_return(form)
end
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[hhmemb])
end
it "has the correct id" do
expect(page.id).to eq("household_members")
end
it "has the correct description" do
expect(page.description).to be_nil
end
end

60
spec/models/form/lettings/questions/hhmemb_spec.rb

@ -0,0 +1,60 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Hhmemb, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, question_definition, page) }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:start_year_2026_or_later?) { false }
let(:form) { instance_double(Form, start_date: current_collection_start_date, start_year_2026_or_later?: start_year_2026_or_later?) }
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct type" do
expect(question.type).to eq("numeric")
end
it "is not marked as derived" do
expect(question.derived?(nil)).to be false
end
it "has the correct id" do
expect(question.id).to eq("hhmemb")
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(0)
end
context "when in 2025", { year: 25 } do
it "does not have check answers card title" do
expect(question.check_answers_card_title).to be_nil
end
it "has the correct question number" do
expect(question.question_number).to eq(30)
end
end
context "when in 2026", { year: 26 } do
let(:start_year_2026_or_later?) { true }
it "has correct check answers card title" do
expect(question.check_answers_card_title).to eq("Household")
end
it "has the correct question number" do
expect(question.question_number).to eq(30)
end
end
end
Loading…
Cancel
Save