From 64b97ab12c31f09a550e25112417582d94d629b7 Mon Sep 17 00:00:00 2001 From: Arthur Campbell Date: Tue, 7 Mar 2023 11:17:02 +0000 Subject: [PATCH] amend page and the other question in that page that determined whether the deleted question should be shown update associated test files --- app/models/form/sales/pages/nationality1.rb | 7 ++--- .../form/sales/questions/nationality1.rb | 10 ------- app/models/sales_log.rb | 4 +++ .../form/sales/pages/nationality1_spec.rb | 12 ++++---- .../form/sales/questions/nationality1_spec.rb | 30 +++++++------------ 5 files changed, 21 insertions(+), 42 deletions(-) diff --git a/app/models/form/sales/pages/nationality1.rb b/app/models/form/sales/pages/nationality1.rb index 96723e857..8db4a64ea 100644 --- a/app/models/form/sales/pages/nationality1.rb +++ b/app/models/form/sales/pages/nationality1.rb @@ -7,15 +7,12 @@ class Form::Sales::Pages::Nationality1 < ::Form::Page "privacynotice" => 1, }, { - "noint" => 1, + "buyer_not_interviewed?" => true, }, ] end def questions - @questions ||= [ - Form::Sales::Questions::Nationality1.new(nil, nil, self), - Form::Sales::Questions::OtherNationality1.new(nil, nil, self), - ] + @questions ||= [Form::Sales::Questions::Nationality1.new(nil, nil, self)] end end diff --git a/app/models/form/sales/questions/nationality1.rb b/app/models/form/sales/questions/nationality1.rb index 53e9edc5f..765489f27 100644 --- a/app/models/form/sales/questions/nationality1.rb +++ b/app/models/form/sales/questions/nationality1.rb @@ -7,16 +7,6 @@ class Form::Sales::Questions::Nationality1 < ::Form::Question @type = "radio" @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @answer_options = ANSWER_OPTIONS - @conditional_for = { - "othernational" => [12], - } - @hidden_in_check_answers = { - "depends_on" => [ - { - "national" => 12, - }, - ], - } @check_answers_card_number = 1 @inferred_check_answers_value = [{ "condition" => { diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 90f130c04..07b0a978f 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -250,6 +250,10 @@ class SalesLog < Log jointpur == 2 end + def buyer_not_interviewed? + noint == 1 + end + def old_persons_shared_ownership? type == 24 end diff --git a/spec/models/form/sales/pages/nationality1_spec.rb b/spec/models/form/sales/pages/nationality1_spec.rb index da5a5f802..37b58a89f 100644 --- a/spec/models/form/sales/pages/nationality1_spec.rb +++ b/spec/models/form/sales/pages/nationality1_spec.rb @@ -1,22 +1,20 @@ require "rails_helper" RSpec.describe Form::Sales::Pages::Nationality1, type: :model do - subject(:page) { described_class.new(page_id, page_definition, subsection) } + subject(:page) { described_class.new(nil, nil, subsection) } - let(:page_id) { nil } - let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } it "has correct subsection" do - expect(page.subsection).to eq(subsection) + expect(page.subsection).to be subsection end it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[national othernational]) + expect(page.questions.map(&:id)).to eq %w[national] end it "has the correct id" do - expect(page.id).to eq("buyer_1_nationality") + expect(page.id).to eq "buyer_1_nationality" end it "has the correct header" do @@ -28,6 +26,6 @@ RSpec.describe Form::Sales::Pages::Nationality1, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }]) + expect(page.depends_on).to eq [{ "privacynotice" => 1 }, { "buyer_not_interviewed?" => true }] end end diff --git a/spec/models/form/sales/questions/nationality1_spec.rb b/spec/models/form/sales/questions/nationality1_spec.rb index 18f659e86..4b8816dbf 100644 --- a/spec/models/form/sales/questions/nationality1_spec.rb +++ b/spec/models/form/sales/questions/nationality1_spec.rb @@ -1,30 +1,28 @@ require "rails_helper" RSpec.describe Form::Sales::Questions::Nationality1, type: :model do - subject(:question) { described_class.new(question_id, question_definition, page) } + subject(:question) { described_class.new(nil, nil, page) } - let(:question_id) { nil } - let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } it "has correct page" do - expect(question.page).to eq(page) + expect(question.page).to be page end it "has the correct id" do - expect(question.id).to eq("national") + expect(question.id).to eq "national" end it "has the correct header" do - expect(question.header).to eq("What is buyer 1’s nationality?") + expect(question.header).to eq "What is buyer 1’s nationality?" end it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Buyer 1’s nationality") + expect(question.check_answer_label).to eq "Buyer 1’s nationality" end it "has the correct type" do - expect(question.type).to eq("radio") + expect(question.type).to eq "radio" end it "is not marked as derived" do @@ -32,7 +30,7 @@ RSpec.describe Form::Sales::Questions::Nationality1, type: :model do end it "has the correct hint" do - expect(question.hint_text).to eq("Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest.") + expect(question.hint_text).to eq "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." end it "has the correct answer_options" do @@ -46,23 +44,15 @@ RSpec.describe Form::Sales::Questions::Nationality1, type: :model do end it "has correct conditional for" do - expect(question.conditional_for).to eq({ - "othernational" => [12], - }) + expect(question.conditional_for).to be_nil end it "has correct hidden in check answers" do - expect(question.hidden_in_check_answers).to eq({ - "depends_on" => [ - { - "national" => 12, - }, - ], - }) + expect(question.hidden_in_check_answers).to be_nil end it "has the correct check_answers_card_number" do - expect(question.check_answers_card_number).to eq(1) + expect(question.check_answers_card_number).to be 1 end it "has the correct inferred_check_answers_value" do