Browse Source

More test fixes

pull/2792/head
Rachael Booth 7 months ago
parent
commit
1cfd81b829
  1. 4
      spec/models/form/lettings/questions/homeless_spec.rb
  2. 42
      spec/models/form/sales/pages/buyer_interview_spec.rb
  3. 37
      spec/models/form/sales/questions/buyer_interview_spec.rb
  4. 4
      spec/models/form/sales/questions/privacy_notice_spec.rb
  5. 4
      spec/models/form/sales/questions/uprn_confirmation_spec.rb

4
spec/models/form/lettings/questions/homeless_spec.rb

@ -28,10 +28,6 @@ RSpec.describe Form::Lettings::Questions::Homeless, type: :model do
}) })
end end
it "has no hint text" do
expect(question.hint_text).to be_empty
end
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(0) expect(question.check_answers_card_number).to eq(0)
end end

42
spec/models/form/sales/pages/buyer_interview_spec.rb

@ -6,7 +6,7 @@ RSpec.describe Form::Sales::Pages::BuyerInterview, type: :model do
let(:page_id) { "buyer_interview" } let(:page_id) { "buyer_interview" }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false) } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false) }
let(:subsection) { instance_double(Form::Subsection, form:, id: "setup") } let(:subsection) { instance_double(Form::Subsection, form:, id: "setup", copy_key: "subsection_copy_key") }
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) expect(page.subsection).to eq(subsection)
@ -24,43 +24,23 @@ RSpec.describe Form::Sales::Pages::BuyerInterview, type: :model do
expect(page.description).to be_nil expect(page.description).to be_nil
end end
context "when form is before 2024" do context "when there are joint buyers" do
let(:subsection) { instance_double(Form::Subsection, form:, id: "household_characteristics") } subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) }
context "when there are joint buyers" do let(:subsection) { instance_double(Form::Subsection, form:, copy_key: "subsection_copy_key") }
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) }
it "has the expected copy_key" do it "has the expected copy_key" do
expect(page.copy_key).to eq("sales.household_characteristics.noint.joint_purchase") expect(page.copy_key).to eq("sales.subsection_copy_key.noint.joint_purchase")
end
end
context "when there is a single buyer" do
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) }
it "has the expected copy_key" do
expect(page.copy_key).to eq("sales.household_characteristics.noint.not_joint_purchase")
end
end end
end end
context "when form is after 2024" do context "when there is a single buyer" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2024_or_later?: true) } subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) }
context "when there are joint buyers" do
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) }
it "has the expected copy_key" do
expect(page.copy_key).to eq("sales.setup.noint.joint_purchase")
end
end
context "when there is a single buyer" do let(:subsection) { instance_double(Form::Subsection, form:, copy_key: "subsection_copy_key") }
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) }
it "has the expected copy_key" do it "has the expected copy_key" do
expect(page.copy_key).to eq("sales.setup.noint.not_joint_purchase") expect(page.copy_key).to eq("sales.subsection_copy_key.noint.not_joint_purchase")
end
end end
end end
end end

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

@ -6,7 +6,8 @@ RSpec.describe Form::Sales::Questions::BuyerInterview, type: :model do
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: true) } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: true) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "setup")) } let(:subsection) { instance_double(Form::Subsection, form:, copy_key: "setup") }
let(:page) { instance_double(Form::Page, subsection:) }
it "has correct page" do it "has correct page" do
expect(question.page).to eq(page) expect(question.page).to eq(page)
@ -34,42 +35,20 @@ RSpec.describe Form::Sales::Questions::BuyerInterview, type: :model do
context "when there are joint buyers" do context "when there are joint buyers" do
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) } subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) }
context "when the form start year is before 2024" do let(:subsection) { instance_double(Form::Subsection, form:, copy_key: "subsection_copy_key") }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "household_characteristics")) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 3, 1), start_year_2024_or_later?: false) }
it "has the expected copy_key" do it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.household_characteristics.noint.joint_purchase") expect(question.copy_key).to eq("sales.subsection_copy_key.noint.joint_purchase")
end
end
context "when the form start year is after 2024" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2024_or_later?: true) }
it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.setup.noint.joint_purchase")
end
end end
end end
context "when there is a single buyer" do context "when there is a single buyer" do
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: false) } subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: false) }
context "when the form start year is before 2024" do let(:subsection) { instance_double(Form::Subsection, form:, copy_key: "subsection_copy_key") }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "household_characteristics")) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false) }
it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.household_characteristics.noint.not_joint_purchase")
end
end
context "when the form start year is after 2024" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2024_or_later?: true) }
it "has the expected copy_key" do it "has the expected copy_key" do
expect(question.copy_key).to eq("sales.setup.noint.not_joint_purchase") expect(question.copy_key).to eq("sales.subsection_copy_key.noint.not_joint_purchase")
end
end end
end end
end end

4
spec/models/form/sales/questions/privacy_notice_spec.rb

@ -6,7 +6,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, 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, id: "setup") } let(:subsection) { instance_double(Form::Subsection, id: "setup", copy_key: "setup") }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) }
before do before do
@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
end end
context "when the form year is before 2024" do context "when the form year is before 2024" do
let(:subsection) { instance_double(Form::Subsection, id: "household_characteristics") } let(:subsection) { instance_double(Form::Subsection, id: "household_characteristics", copy_key: "household_characteristics") }
before do before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(form).to receive(:start_year_2024_or_later?).and_return(false)

4
spec/models/form/sales/questions/uprn_confirmation_spec.rb

@ -25,10 +25,6 @@ RSpec.describe Form::Sales::Questions::UprnConfirmation, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
it "has the correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must answer #{format_ending(I18n.t('forms.2023.sales.property_information.uprn_confirmed.check_answer_label'))}")
end
describe "notification_banner" do describe "notification_banner" do
context "when address is not present" do context "when address is not present" do
it "returns nil" do it "returns nil" do

Loading…
Cancel
Save