Browse Source

Merge branch 'main' into AllowStagingTesting

pull/2279/head
Rachael Booth 2 years ago committed by GitHub
parent
commit
bb0b7bea0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/models/form/lettings/questions/reason.rb
  2. 2
      app/models/form/lettings/questions/reason_renewal.rb
  3. 5
      app/models/form/sales/questions/living_before_purchase_years.rb
  4. 5
      app/models/form/sales/questions/mortgage_length.rb
  5. 2
      spec/models/form/lettings/questions/reason_renewal_spec.rb
  6. 2
      spec/models/form/lettings/questions/reason_spec.rb
  7. 25
      spec/models/form/sales/questions/living_before_purchase_years_spec.rb
  8. 20
      spec/models/form/sales/questions/mortgage_length_spec.rb

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

@ -21,7 +21,7 @@ class Form::Lettings::Questions::Reason < ::Form::Question
"50" => { "value" => "End of social housing tenancy - no fault" }, "50" => { "value" => "End of social housing tenancy - no fault" },
"51" => { "value" => "End of social housing tenancy - evicted due to anti-social behaviour (ASB)" }, "51" => { "value" => "End of social housing tenancy - evicted due to anti-social behaviour (ASB)" },
"52" => { "value" => "End of social housing tenancy - evicted due to rent arrears" }, "52" => { "value" => "End of social housing tenancy - evicted due to rent arrears" },
"53" => { "value" => "End of fixed term tenancy - evicted for any other reason" }, "53" => { "value" => "End of social housing tenancy - evicted for any other reason" },
"1" => { "value" => "Permanently decanted from another property owned by this landlord" }, "1" => { "value" => "Permanently decanted from another property owned by this landlord" },
"2" => { "value" => "Left home country as a refugee" }, "2" => { "value" => "Left home country as a refugee" },
"45" => { "value" => "Discharged from prison" }, "45" => { "value" => "Discharged from prison" },

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

@ -21,7 +21,7 @@ class Form::Lettings::Questions::ReasonRenewal < ::Form::Question
"50" => { "value" => "End of social housing tenancy - no fault" }, "50" => { "value" => "End of social housing tenancy - no fault" },
"51" => { "value" => "End of social housing tenancy - evicted due to anti-social behaviour (ASB)" }, "51" => { "value" => "End of social housing tenancy - evicted due to anti-social behaviour (ASB)" },
"52" => { "value" => "End of social housing tenancy - evicted due to rent arrears" }, "52" => { "value" => "End of social housing tenancy - evicted due to rent arrears" },
"53" => { "value" => "End of fixed term tenancy - evicted for any other reason" }, "53" => { "value" => "End of social housing tenancy - evicted for any other reason" },
"20" => { "value" => "Other" }, "20" => { "value" => "Other" },
"47" => { "value" => "Tenant prefers not to say" }, "47" => { "value" => "Tenant prefers not to say" },
"divider" => { "value" => true }, "divider" => { "value" => true },

5
app/models/form/sales/questions/living_before_purchase_years.rb

@ -10,7 +10,6 @@ class Form::Sales::Questions::LivingBeforePurchaseYears < ::Form::Question
@max = 80 @max = 80
@step = 1 @step = 1
@width = 5 @width = 5
@suffix = " years"
@ownershipsch = ownershipsch @ownershipsch = ownershipsch
@question_number = question_number @question_number = question_number
end end
@ -39,4 +38,8 @@ class Form::Sales::Questions::LivingBeforePurchaseYears < ::Form::Question
99 99
end end
end end
def suffix_label(log)
" #{'year'.pluralize(log[id])}"
end
end end

5
app/models/form/sales/questions/mortgage_length.rb

@ -9,7 +9,6 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question
@max = 60 @max = 60
@step = 1 @step = 1
@width = 5 @width = 5
@suffix = " years"
@hint_text = "You should round up to the nearest year. Value should not exceed 60 years." @hint_text = "You should round up to the nearest year. Value should not exceed 60 years."
@ownershipsch = ownershipsch @ownershipsch = ownershipsch
@question_number = question_number @question_number = question_number
@ -25,4 +24,8 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question
114 114
end end
end end
def suffix_label(log)
" #{'year'.pluralize(log[id])}"
end
end end

2
spec/models/form/lettings/questions/reason_renewal_spec.rb

@ -74,7 +74,7 @@ RSpec.describe Form::Lettings::Questions::ReasonRenewal, type: :model do
"50" => { "value" => "End of social housing tenancy - no fault" }, "50" => { "value" => "End of social housing tenancy - no fault" },
"51" => { "value" => "End of social housing tenancy - evicted due to anti-social behaviour (ASB)" }, "51" => { "value" => "End of social housing tenancy - evicted due to anti-social behaviour (ASB)" },
"52" => { "value" => "End of social housing tenancy - evicted due to rent arrears" }, "52" => { "value" => "End of social housing tenancy - evicted due to rent arrears" },
"53" => { "value" => "End of fixed term tenancy - evicted for any other reason" }, "53" => { "value" => "End of social housing tenancy - evicted for any other reason" },
"20" => { "value" => "Other" }, "20" => { "value" => "Other" },
"47" => { "value" => "Tenant prefers not to say" }, "47" => { "value" => "Tenant prefers not to say" },
"divider" => { "value" => true }, "divider" => { "value" => true },

2
spec/models/form/lettings/questions/reason_spec.rb

@ -108,7 +108,7 @@ RSpec.describe Form::Lettings::Questions::Reason, type: :model do
"50" => { "value" => "End of social housing tenancy - no fault" }, "50" => { "value" => "End of social housing tenancy - no fault" },
"51" => { "value" => "End of social housing tenancy - evicted due to anti-social behaviour (ASB)" }, "51" => { "value" => "End of social housing tenancy - evicted due to anti-social behaviour (ASB)" },
"52" => { "value" => "End of social housing tenancy - evicted due to rent arrears" }, "52" => { "value" => "End of social housing tenancy - evicted due to rent arrears" },
"53" => { "value" => "End of fixed term tenancy - evicted for any other reason" }, "53" => { "value" => "End of social housing tenancy - evicted for any other reason" },
"1" => { "value" => "Permanently decanted from another property owned by this landlord" }, "1" => { "value" => "Permanently decanted from another property owned by this landlord" },
"2" => { "value" => "Left home country as a refugee" }, "2" => { "value" => "Left home country as a refugee" },
"45" => { "value" => "Discharged from prison" }, "45" => { "value" => "Discharged from prison" },

25
spec/models/form/sales/questions/living_before_purchase_years_spec.rb

@ -5,6 +5,7 @@ RSpec.describe Form::Sales::Questions::LivingBeforePurchaseYears, type: :model d
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:start_date) { Time.utc(2024, 2, 8) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) } let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
let(:page) { instance_double(Form::Page, subsection:) } let(:page) { instance_double(Form::Page, subsection:) }
@ -47,10 +48,6 @@ RSpec.describe Form::Sales::Questions::LivingBeforePurchaseYears, type: :model d
expect(question.step).to eq(1) expect(question.step).to eq(1)
end end
it "has correct suffix" do
expect(question.suffix).to eq(" years")
end
it "has correct min" do it "has correct min" do
expect(question.min).to eq(0) expect(question.min).to eq(0)
end end
@ -99,10 +96,6 @@ RSpec.describe Form::Sales::Questions::LivingBeforePurchaseYears, type: :model d
expect(question.step).to eq(1) expect(question.step).to eq(1)
end end
it "has correct suffix" do
expect(question.suffix).to eq(" years")
end
it "has correct min" do it "has correct min" do
expect(question.min).to eq(0) expect(question.min).to eq(0)
end end
@ -111,4 +104,20 @@ RSpec.describe Form::Sales::Questions::LivingBeforePurchaseYears, type: :model d
expect(question.max).to eq(80) expect(question.max).to eq(80)
end end
end end
context "when 1 year" do
let(:sales_log) { FactoryBot.build(:sales_log, proplen: 1) }
it "has correct suffix" do
expect(question.suffix_label(sales_log)).to eq(" year")
end
end
context "when multiple years" do
let(:sales_log) { FactoryBot.build(:sales_log, proplen: 5) }
it "has correct suffix" do
expect(question.suffix_label(sales_log)).to eq(" years")
end
end
end end

20
spec/models/form/sales/questions/mortgage_length_spec.rb

@ -41,10 +41,6 @@ RSpec.describe Form::Sales::Questions::MortgageLength, type: :model do
expect(question.width).to eq(5) expect(question.width).to eq(5)
end end
it "has correct suffix" do
expect(question.suffix).to eq(" years")
end
it "has correct min" do it "has correct min" do
expect(question.min).to eq(0) expect(question.min).to eq(0)
end end
@ -52,4 +48,20 @@ RSpec.describe Form::Sales::Questions::MortgageLength, type: :model do
it "has correct max" do it "has correct max" do
expect(question.max).to eq(60) expect(question.max).to eq(60)
end end
context "when 1 year" do
let(:sales_log) { FactoryBot.build(:sales_log, mortlen: 1) }
it "has correct suffix" do
expect(question.suffix_label(sales_log)).to eq(" year")
end
end
context "when multiple years" do
let(:sales_log) { FactoryBot.build(:sales_log, mortlen: 5) }
it "has correct suffix" do
expect(question.suffix_label(sales_log)).to eq(" years")
end
end
end end

Loading…
Cancel
Save