Browse Source

CLDC-3504 Update period question options and error message (#2463)

* Update displayed_answer_options for period

* Update invalid rent period error message
pull/2475/head
kosiakkatrina 7 months ago committed by GitHub
parent
commit
a85fed42b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      app/models/form/lettings/questions/period.rb
  2. 2
      config/locales/en.yml
  3. 35
      spec/models/form/lettings/questions/period_spec.rb

8
app/models/form/lettings/questions/period.rb

@ -26,4 +26,12 @@ class Form::Lettings::Questions::Period < ::Form::Question
}.freeze
QUESTION_NUMBER_FROM_YEAR = { 2023 => 92, 2024 => 91 }.freeze
def displayed_answer_options(log, _user)
return ANSWER_OPTIONS if log.managing_organisation.nil?
available_rent_periods = log.managing_organisation.rent_periods
ANSWER_OPTIONS.select { |key, _| available_rent_periods.include?(key.to_i) }
end
end

2
config/locales/en.yml

@ -429,7 +429,7 @@ en:
under_10: "Enter a total charge that is at least £10.00 per week"
less_than_shortfall: "The total charge must be more than the outstanding amount"
rent_period:
invalid_for_org: "%{org_name} does not charge rent %{rent_period}"
invalid_for_org: "%{org_name} does not use %{rent_period} as a rent period. Choose another rent period, or a data coordinator can add rent periods to your organisation"
carehome:
out_of_range: "Household rent and other charges must be between %{min_chcharge} and %{max_chcharge} if paying %{period}"
not_provided: "Enter how much rent and other charges the household pays %{period}"

35
spec/models/form/lettings/questions/period_spec.rb

@ -8,4 +8,39 @@ RSpec.describe Form::Lettings::Questions::Period, type: :model do
it "has the correct hint" do
expect(question.hint_text).to eq("Select how often the household is charged. This may be different to how often they pay.")
end
it "has correct answer options" do
expect(question.answer_options).to eq(
{
"2" => { "value" => "Every 2 weeks" },
"3" => { "value" => "Every 4 weeks" },
"4" => { "value" => "Every calendar month" },
"9" => { "value" => "Weekly for 46 weeks" },
"8" => { "value" => "Weekly for 47 weeks" },
"7" => { "value" => "Weekly for 48 weeks" },
"6" => { "value" => "Weekly for 49 weeks" },
"5" => { "value" => "Weekly for 50 weeks" },
"11" => { "value" => "Weekly for 51 weeks" },
"1" => { "value" => "Weekly for 52 weeks" },
"10" => { "value" => "Weekly for 53 weeks" },
},
)
end
context "when managing organisation has rent periods" do
let(:managing_organisation) { create(:organisation, skip_rent_period_creation: true) }
let(:log) { create(:lettings_log, managing_organisation:) }
before do
create(:organisation_rent_period, organisation: managing_organisation, rent_period: 3)
end
it "has correct displayed answer options" do
expect(question.displayed_answer_options(log, nil)).to eq(
{
"3" => { "value" => "Every 4 weeks" },
},
)
end
end
end

Loading…
Cancel
Save