Browse Source

More test fixes

pull/2672/head
Rachael Booth 9 months ago
parent
commit
594fb9c2e8
  1. 4
      config/locales/forms/2023/sales/setup.en.yml
  2. 4
      config/locales/forms/2024/sales/setup.en.yml
  3. 4
      spec/models/form/sales/pages/buyer_company_spec.rb
  4. 6
      spec/models/form/sales/pages/buyer_live_spec.rb
  5. 4
      spec/models/form/sales/pages/joint_purchase_spec.rb
  6. 4
      spec/models/form/sales/pages/managing_organisation_spec.rb
  7. 4
      spec/models/form/sales/pages/number_joint_buyers_spec.rb
  8. 18
      spec/models/form/sales/pages/outright_ownership_type_spec.rb
  9. 4
      spec/models/form/sales/pages/ownership_scheme_spec.rb
  10. 4
      spec/models/form/sales/pages/owning_organisation_spec.rb
  11. 4
      spec/models/form/sales/pages/sale_date_spec.rb
  12. 23
      spec/models/form/sales/pages/shared_ownership_type_spec.rb
  13. 28
      spec/models/form/sales/questions/buyer_interview_spec.rb
  14. 26
      spec/models/form/sales/questions/buyer_live_spec.rb
  15. 12
      spec/models/form/sales/questions/created_by_id_spec.rb
  16. 28
      spec/models/form/sales/questions/joint_purchase_spec.rb
  17. 12
      spec/models/form/sales/questions/managing_organisation_spec.rb
  18. 12
      spec/models/form/sales/questions/number_joint_buyers_spec.rb
  19. 8
      spec/models/form/sales/questions/outright_ownership_type_spec.rb
  20. 12
      spec/models/form/sales/questions/owning_organisation_id_spec.rb
  21. 46
      spec/models/form/sales/questions/shared_ownership_type_spec.rb

4
config/locales/forms/2023/sales/setup.en.yml

@ -89,12 +89,12 @@ en:
joint_purchase:
page_header: ""
check_answer_label: "Buyers interviewed in person?"
hint_text: "You should still try to answer all questions even if the buyers weren't interviewed in person"
hint_text: "You should still try to answer all questions even if the buyers werent interviewed in person"
question_text: "Were the buyers interviewed for any of the answers you will provide on this log?"
not_joint_purchase:
page_header: ""
check_answer_label: "Buyer interviewed in person?"
hint_text: "You should still try to answer all questions even if the buyer wasn't interviewed in person"
hint_text: "You should still try to answer all questions even if the buyer wasnt interviewed in person"
question_text: "Was the buyer interviewed for any of the answers you will provide on this log?"
privacynotice:

4
config/locales/forms/2024/sales/setup.en.yml

@ -89,12 +89,12 @@ en:
joint_purchase:
page_header: ""
check_answer_label: "Buyers interviewed in person?"
hint_text: "You should still try to answer all questions even if the buyers weren't interviewed in person"
hint_text: "You should still try to answer all questions even if the buyers werent interviewed in person"
question_text: "Were the buyers interviewed for any of the answers you will provide on this log?"
not_joint_purchase:
page_header: ""
check_answer_label: "Buyer interviewed in person?"
hint_text: "You should still try to answer all questions even if the buyer wasn't interviewed in person"
hint_text: "You should still try to answer all questions even if the buyer wasnt interviewed in person"
question_text: "Was the buyer interviewed for any of the answers you will provide on this log?"
privacynotice:

4
spec/models/form/sales/pages/buyer_company_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Sales::Pages::BuyerCompany, type: :model do
expect(page.id).to eq("buyer_company")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end

6
spec/models/form/sales/pages/buyer_live_spec.rb

@ -1,15 +1,17 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::BuyerLive, 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: Time.zone.local(2023, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
allow(form).to receive(:start_year_after_2024?).and_return(true)
allow(subsection).to receive(:form).and_return(form)
end

4
spec/models/form/sales/pages/joint_purchase_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Sales::Pages::JointPurchase, type: :model do
expect(page.id).to eq("joint_purchase")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end

4
spec/models/form/sales/pages/managing_organisation_spec.rb

@ -20,10 +20,6 @@ RSpec.describe Form::Sales::Pages::ManagingOrganisation, type: :model do
expect(page.id).to eq("managing_organisation")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end

4
spec/models/form/sales/pages/number_joint_buyers_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Sales::Pages::NumberJointBuyers, type: :model do
expect(page.id).to eq("number_joint_buyers")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end

18
spec/models/form/sales/pages/outright_ownership_type_spec.rb

@ -29,22 +29,4 @@ RSpec.describe Form::Sales::Pages::OutrightOwnershipType, type: :model do
"ownershipsch" => 3,
}])
end
describe "headers" do
context "when the form year is 2023/24" do
let(:start_date) { Time.zone.local(2023, 4, 8) }
it "has the correct header" do
expect(page.header).to eq("Type of outright sale")
end
end
context "when the form is before the year 2023/24" do
let(:start_date) { Time.zone.local(2022, 4, 8) }
it "does not have a page header" do
expect(page.header).to eq(nil)
end
end
end
end

4
spec/models/form/sales/pages/ownership_scheme_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Sales::Pages::OwnershipScheme, type: :model do
expect(page.id).to eq("ownership_scheme")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end

4
spec/models/form/sales/pages/owning_organisation_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Sales::Pages::OwningOrganisation, type: :model do
expect(page.id).to eq("owning_organisation")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end

4
spec/models/form/sales/pages/sale_date_spec.rb

@ -19,10 +19,6 @@ RSpec.describe Form::Sales::Pages::SaleDate, type: :model do
expect(page.id).to eq("completion_date")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end

23
spec/models/form/sales/pages/shared_ownership_type_spec.rb

@ -1,30 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::SharedOwnershipType, 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, form: instance_double(Form, start_date:, start_year_after_2024?: false)) }
let(:start_date) { Time.utc(2022, 4, 1) }
describe "headers" do
context "when form is after the year 2023/24" do
let(:start_date) { Time.zone.local(2023, 4, 8) }
it "has the correct header" do
expect(page.header).to eq("Type of shared ownership sale")
end
end
context "when form is before the year 2023/24" do
let(:start_date) { Time.zone.local(2022, 2, 8) }
it "has the correct header" do
expect(page.header).to eq(nil)
end
end
end
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date, start_year_after_2024?: true)) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)

28
spec/models/form/sales/questions/buyer_interview_spec.rb

@ -15,14 +15,6 @@ RSpec.describe Form::Sales::Questions::BuyerInterview, type: :model do
expect(question.id).to eq("noint")
end
it "has the correct header" do
expect(question.header).to eq("Was the buyer interviewed for any of the answers you will provide on this log?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyer interviewed in person?")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
@ -31,30 +23,10 @@ RSpec.describe Form::Sales::Questions::BuyerInterview, type: :model do
expect(question.derived?(nil)).to be false
end
it "has the correct hint" do
expect(question.hint_text).to eq("You should still try to answer all questions even if the buyer wasn’t interviewed in person")
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"2" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
context "with joint purchase" do
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) }
it "has the correct header" do
expect(question.header).to eq("Were the buyers interviewed for any of the answers you will provide on this log?")
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("You should still try to answer all questions even if the buyers weren’t interviewed in person")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyers interviewed in person?")
end
end
end

26
spec/models/form/sales/questions/buyer_live_spec.rb

@ -1,16 +1,18 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::BuyerLive, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
allow(form).to receive(:start_year_after_2024?).and_return(true)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
@ -23,10 +25,6 @@ RSpec.describe Form::Sales::Questions::BuyerLive, type: :model do
expect(question.id).to eq("buylivein")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyers living in property")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
@ -41,20 +39,4 @@ RSpec.describe Form::Sales::Questions::BuyerLive, type: :model do
"2" => { "value" => "No" },
})
end
context "with 2023/24 form" do
it "has the correct header" do
expect(question.header).to eq("Will the buyers live in the property?")
end
end
context "with 2024/25 form" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has the correct header" do
expect(question.header).to eq("Will any buyers live in the property?")
end
end
end

12
spec/models/form/sales/questions/created_by_id_spec.rb

@ -17,22 +17,10 @@ RSpec.describe Form::Sales::Questions::CreatedById, type: :model do
expect(question.id).to eq("assigned_to_id")
end
it "has the correct header" do
expect(question.header).to eq("Which user are you creating this log for?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Log owner")
end
it "has the correct type" do
expect(question.type).to eq("select")
end
it "has the correct hint_text" do
expect(question.hint_text).to be_nil
end
it "is marked as derived" do
expect(question.derived?(nil)).to be true
end

28
spec/models/form/sales/questions/joint_purchase_spec.rb

@ -22,14 +22,6 @@ RSpec.describe Form::Sales::Questions::JointPurchase, type: :model do
expect(question.id).to eq("jointpur")
end
it "has the correct header" do
expect(question.header).to eq("Is this a joint purchase?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Joint purchase")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
@ -44,24 +36,4 @@ RSpec.describe Form::Sales::Questions::JointPurchase, type: :model do
"2" => { "value" => "No" },
})
end
context "with collection year before 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has the blank hint_text" do
expect(question.hint_text).to be_nil
end
end
context "with collection year >= 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("This is where two or more people are named as legal owners of the property after the purchase")
end
end
end

12
spec/models/form/sales/questions/managing_organisation_spec.rb

@ -15,22 +15,10 @@ RSpec.describe Form::Sales::Questions::ManagingOrganisation, type: :model do
expect(question.id).to eq("managing_organisation_id")
end
it "has the correct header" do
expect(question.header).to eq("Which organisation is reporting this sale?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Reported by")
end
it "has the correct type" do
expect(question.type).to eq("select")
end
it "has the correct hint_text" do
expect(question.hint_text).to be_nil
end
describe "#displayed_answer_options" do
let(:options) { { "" => "Select an option" } }

12
spec/models/form/sales/questions/number_joint_buyers_spec.rb

@ -21,14 +21,6 @@ RSpec.describe Form::Sales::Questions::NumberJointBuyers, type: :model do
expect(question.id).to eq("jointmore")
end
it "has the correct header" do
expect(question.header).to eq("Are there more than 2 joint buyers of this property?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("More than 2 joint buyers")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
@ -37,10 +29,6 @@ RSpec.describe Form::Sales::Questions::NumberJointBuyers, type: :model do
expect(question.derived?(nil)).to be false
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("You should still try to answer all questions even if the buyers weren’t interviewed in person")
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Yes" },

8
spec/models/form/sales/questions/outright_ownership_type_spec.rb

@ -17,10 +17,6 @@ RSpec.describe Form::Sales::Questions::OutrightOwnershipType, type: :model do
expect(question.id).to eq("type")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Type of outright sale")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
@ -42,10 +38,6 @@ RSpec.describe Form::Sales::Questions::OutrightOwnershipType, type: :model do
})
end
it "has the correct header" do
expect(question.header).to eq("What is the type of outright sale?")
end
describe "partial guidance" do
context "when the form is for year 2023/24" do
let(:start_date) { Time.zone.local(2023, 4, 8) }

12
spec/models/form/sales/questions/owning_organisation_id_spec.rb

@ -26,22 +26,10 @@ RSpec.describe Form::Sales::Questions::OwningOrganisationId, type: :model do
expect(question.id).to eq("owning_organisation_id")
end
it "has the correct header" do
expect(question.header).to eq("Which organisation owns this log?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Owning organisation")
end
it "has the correct type" do
expect(question.type).to eq("select")
end
it "has the correct hint_text" do
expect(question.hint_text).to be_nil
end
describe "answer options" do
let(:options) { { "" => "Select an option" } }

46
spec/models/form/sales/questions/shared_ownership_type_spec.rb

@ -1,17 +1,19 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:start_date) { Time.zone.local(2022, 4, 1) }
let(:start_date) { current_collection_start_date }
let(:form) { instance_double(Form, start_date:) }
let(:subsection) { instance_double(Form::Subsection, form:) }
let(:page) { instance_double(Form::Page, subsection:) }
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has correct page" do
@ -22,14 +24,6 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do
expect(question.id).to eq("type")
end
it "has the correct header" do
expect(question.header).to eq("What is the type of shared ownership sale?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Type of shared ownership sale")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
@ -38,33 +32,13 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do
expect(question.derived?(nil)).to be false
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("A shared ownership sale is when the purchaser buys up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion")
end
context "when form start date is 2022/23" do
let(:start_date) { Time.zone.local(2022, 4, 1) }
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"2" => { "value" => "Shared Ownership" },
"24" => { "value" => "Old Persons Shared Ownership" },
"18" => { "value" => "Social HomeBuy (shared ownership purchase)" },
"16" => { "value" => "Home Ownership for people with Long-Term Disabilities (HOLD)" },
"28" => { "value" => "Rent to Buy - Shared Ownership" },
"31" => { "value" => "Right to Shared Ownership" },
"30" => { "value" => "Shared Ownership - 2021 model lease" },
})
end
it "does not show a top_guidance_partial" do
expect(question.top_guidance_partial).to eq(nil)
end
end
context "when form start date is 2023/24" do
let(:start_date) { Time.zone.local(2023, 4, 2) }
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"2" => { "value" => "Shared Ownership (old model lease)" },
@ -91,9 +65,5 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do
it "shows shows correct top_guidance_partial" do
expect(question.top_guidance_partial).to eq("shared_ownership_type_definitions_2024")
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("When the purchaser buys an initial share of up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion, or a subsequent staircasing transaction")
end
end
end

Loading…
Cancel
Save