From a954bcb6178068a9b8678f9d209dc9277048fa65 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Thu, 15 Jun 2023 12:09:58 +0100 Subject: [PATCH] feat: update tests --- spec/helpers/question_view_helper_spec.rb | 4 ++ .../lettings/questions/address_line1_spec.rb | 40 +++-------------- .../form/lettings/questions/county_spec.rb | 10 ++--- .../postcode_for_full_address_spec.rb | 10 ++--- .../lettings/questions/town_or_city_spec.rb | 10 ++--- .../sales/questions/address_line1_spec.rb | 44 ++++--------------- .../form/sales/questions/county_spec.rb | 10 ++--- .../postcode_for_full_address_spec.rb | 10 ++--- .../form/sales/questions/town_or_city_spec.rb | 10 ++--- .../lettings/year2023/row_parser_spec.rb | 8 ++-- 10 files changed, 54 insertions(+), 102 deletions(-) diff --git a/spec/helpers/question_view_helper_spec.rb b/spec/helpers/question_view_helper_spec.rb index c24540709..bf9eefe98 100644 --- a/spec/helpers/question_view_helper_spec.rb +++ b/spec/helpers/question_view_helper_spec.rb @@ -53,6 +53,10 @@ RSpec.describe QuestionViewHelper do def plain_label nil end + + def hide_question_number_on_page + false + end end end diff --git a/spec/models/form/lettings/questions/address_line1_spec.rb b/spec/models/form/lettings/questions/address_line1_spec.rb index 8b55d86c5..0fc91a586 100644 --- a/spec/models/form/lettings/questions/address_line1_spec.rb +++ b/spec/models/form/lettings/questions/address_line1_spec.rb @@ -19,12 +19,16 @@ RSpec.describe Form::Lettings::Questions::AddressLine1, type: :model do expect(question.header).to eq("Address line 1") end - it "has the correct question_number" do - expect(question.question_number).to be_nil + it "has the correct error label" do + expect(question.error_label).to eq("Address line 1") end it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Q12 - Address lines 1 and 2") + expect(question.check_answer_label).to eq("Address lines 1 and 2") + end + + it "has the correct question_number" do + expect(question.question_number).to eq(12) end it "has the correct type" do @@ -46,34 +50,4 @@ RSpec.describe Form::Lettings::Questions::AddressLine1, type: :model do it "has the correct check_answers_card_number" do expect(question.check_answers_card_number).to be_nil end - - describe "has the correct get_extra_check_answer_value" do - context "when la is not present" do - let(:log) { create(:lettings_log, la: nil) } - - it "returns nil" do - expect(question.get_extra_check_answer_value(log)).to be_nil - end - end - - context "when la is present but not inferred" do - let(:log) { create(:lettings_log, la: "E09000003", is_la_inferred: false) } - - it "returns nil" do - expect(question.get_extra_check_answer_value(log)).to be_nil - end - end - - context "when la is present and inferred" do - let(:log) { create(:lettings_log, la: "E09000003") } - - before do - allow(log).to receive(:is_la_inferred?).and_return(true) - end - - it "returns the la" do - expect(question.get_extra_check_answer_value(log)).to eq("Barnet") - end - end - end end diff --git a/spec/models/form/lettings/questions/county_spec.rb b/spec/models/form/lettings/questions/county_spec.rb index 96abb6acc..1955dad8f 100644 --- a/spec/models/form/lettings/questions/county_spec.rb +++ b/spec/models/form/lettings/questions/county_spec.rb @@ -20,7 +20,11 @@ RSpec.describe Form::Lettings::Questions::County, type: :model do end it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Q12 - County") + expect(question.check_answer_label).to eq("County") + end + + it "has the correct question_number" do + expect(question.question_number).to eq(12) end it "has the correct type" do @@ -42,8 +46,4 @@ RSpec.describe Form::Lettings::Questions::County, type: :model do it "has the correct check_answers_card_number" do expect(question.check_answers_card_number).to be_nil end - - it "has the correct hidden_in_check_answers" do - expect(question.hidden_in_check_answers?).to eq(true) - end end diff --git a/spec/models/form/lettings/questions/postcode_for_full_address_spec.rb b/spec/models/form/lettings/questions/postcode_for_full_address_spec.rb index a8127d5c4..337d1e6fe 100644 --- a/spec/models/form/lettings/questions/postcode_for_full_address_spec.rb +++ b/spec/models/form/lettings/questions/postcode_for_full_address_spec.rb @@ -20,7 +20,11 @@ RSpec.describe Form::Lettings::Questions::PostcodeForFullAddress, type: :model d end it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Q12 - Postcode") + expect(question.check_answer_label).to eq("Postcode") + end + + it "has the correct question_number" do + expect(question.question_number).to eq(12) end it "has the correct type" do @@ -55,8 +59,4 @@ RSpec.describe Form::Lettings::Questions::PostcodeForFullAddress, type: :model d "value" => "Not known", }]) end - - it "has the correct hidden_in_check_answers" do - expect(question.hidden_in_check_answers?).to eq(true) - end end diff --git a/spec/models/form/lettings/questions/town_or_city_spec.rb b/spec/models/form/lettings/questions/town_or_city_spec.rb index 65f1ea13d..a18d63c04 100644 --- a/spec/models/form/lettings/questions/town_or_city_spec.rb +++ b/spec/models/form/lettings/questions/town_or_city_spec.rb @@ -20,7 +20,11 @@ RSpec.describe Form::Lettings::Questions::TownOrCity, type: :model do end it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Q12 - Town or city") + expect(question.check_answer_label).to eq("Town or city") + end + + it "has the correct question_number" do + expect(question.question_number).to eq(12) end it "has the correct type" do @@ -42,8 +46,4 @@ RSpec.describe Form::Lettings::Questions::TownOrCity, type: :model do it "has the correct check_answers_card_number" do expect(question.check_answers_card_number).to be_nil end - - it "has the correct hidden_in_check_answers" do - expect(question.hidden_in_check_answers?).to eq(true) - end end diff --git a/spec/models/form/sales/questions/address_line1_spec.rb b/spec/models/form/sales/questions/address_line1_spec.rb index d39cb93fd..12643a27d 100644 --- a/spec/models/form/sales/questions/address_line1_spec.rb +++ b/spec/models/form/sales/questions/address_line1_spec.rb @@ -11,10 +11,6 @@ RSpec.describe Form::Sales::Questions::AddressLine1, type: :model do expect(question.page).to eq(page) end - it "has the correct question_number" do - expect(question.question_number).to be_nil - end - it "has the correct id" do expect(question.id).to eq("address_line1") end @@ -23,8 +19,16 @@ RSpec.describe Form::Sales::Questions::AddressLine1, type: :model do expect(question.header).to eq("Address line 1") end + it "has the correct error label" do + expect(question.error_label).to eq("Address line 1") + end + it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Q15 - Address lines 1 and 2") + expect(question.check_answer_label).to eq("Address lines 1 and 2") + end + + it "has the correct question_number" do + expect(question.question_number).to eq(15) end it "has the correct type" do @@ -46,34 +50,4 @@ RSpec.describe Form::Sales::Questions::AddressLine1, type: :model do it "has the correct check_answers_card_number" do expect(question.check_answers_card_number).to be_nil end - - describe "has the correct get_extra_check_answer_value" do - context "when la is not present" do - let(:log) { create(:sales_log, la: nil) } - - it "returns nil" do - expect(question.get_extra_check_answer_value(log)).to be_nil - end - end - - context "when la is present but not inferred" do - let(:log) { create(:sales_log, la: "E09000003", is_la_inferred: false) } - - it "returns nil" do - expect(question.get_extra_check_answer_value(log)).to be_nil - end - end - - context "when la is present and inferred" do - let(:log) { create(:sales_log, la: "E09000003") } - - before do - allow(log).to receive(:is_la_inferred?).and_return(true) - end - - it "returns the la" do - expect(question.get_extra_check_answer_value(log)).to eq("Barnet") - end - end - end end diff --git a/spec/models/form/sales/questions/county_spec.rb b/spec/models/form/sales/questions/county_spec.rb index 5d02209d4..19bb59eb4 100644 --- a/spec/models/form/sales/questions/county_spec.rb +++ b/spec/models/form/sales/questions/county_spec.rb @@ -20,7 +20,11 @@ RSpec.describe Form::Sales::Questions::County, type: :model do end it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Q15 - County") + expect(question.check_answer_label).to eq("County") + end + + it "has the correct question_number" do + expect(question.question_number).to eq(15) end it "has the correct type" do @@ -42,8 +46,4 @@ RSpec.describe Form::Sales::Questions::County, type: :model do it "has the correct check_answers_card_number" do expect(question.check_answers_card_number).to be_nil end - - it "has the correct hidden_in_check_answers" do - expect(question.hidden_in_check_answers?).to eq(true) - end end diff --git a/spec/models/form/sales/questions/postcode_for_full_address_spec.rb b/spec/models/form/sales/questions/postcode_for_full_address_spec.rb index 63f305321..a3c8ddfb8 100644 --- a/spec/models/form/sales/questions/postcode_for_full_address_spec.rb +++ b/spec/models/form/sales/questions/postcode_for_full_address_spec.rb @@ -20,7 +20,11 @@ RSpec.describe Form::Sales::Questions::PostcodeForFullAddress, type: :model do end it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Q15 - Postcode") + expect(question.check_answer_label).to eq("Postcode") + end + + it "has the correct question_number" do + expect(question.question_number).to eq(15) end it "has the correct type" do @@ -55,8 +59,4 @@ RSpec.describe Form::Sales::Questions::PostcodeForFullAddress, type: :model do "value" => "Not known", }]) end - - it "has the correct hidden_in_check_answers" do - expect(question.hidden_in_check_answers?).to eq(true) - end end diff --git a/spec/models/form/sales/questions/town_or_city_spec.rb b/spec/models/form/sales/questions/town_or_city_spec.rb index 83b32ef67..df1c905b4 100644 --- a/spec/models/form/sales/questions/town_or_city_spec.rb +++ b/spec/models/form/sales/questions/town_or_city_spec.rb @@ -20,7 +20,11 @@ RSpec.describe Form::Sales::Questions::TownOrCity, type: :model do end it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Q15 - Town or city") + expect(question.check_answer_label).to eq("Town or city") + end + + it "has the correct question_number" do + expect(question.question_number).to eq(15) end it "has the correct type" do @@ -42,8 +46,4 @@ RSpec.describe Form::Sales::Questions::TownOrCity, type: :model do it "has the correct check_answers_card_number" do expect(question.check_answers_card_number).to be_nil end - - it "has the correct hidden_in_check_answers" do - expect(question.hidden_in_check_answers?).to eq(true) - end end diff --git a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb index 0a4bef0c3..b03837179 100644 --- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb @@ -340,8 +340,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do it "fetches the question's check_answer_label if it exists, otherwise it gets the question's header" do parser.valid? - expect(parser.errors[:field_19]).to eql(["You must answer q12 - address lines 1 and 2"]) - expect(parser.errors[:field_21]).to eql(["You must answer q12 - town or city"]) + expect(parser.errors[:field_19]).to eql(["You must answer address line 1"]) + expect(parser.errors[:field_21]).to eql(["You must answer town or city"]) end end end @@ -937,8 +937,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do it "adds appropriate errors" do expect(parser.errors[:field_18]).to eql(["You must answer UPRN"]) - expect(parser.errors[:field_19]).to eql(["You must answer q12 - address lines 1 and 2"]) - expect(parser.errors[:field_21]).to eql(["You must answer q12 - town or city"]) + expect(parser.errors[:field_19]).to eql(["You must answer address line 1"]) + expect(parser.errors[:field_21]).to eql(["You must answer town or city"]) end end