Browse Source

amend page and the other question in that page that determined whether the deleted question should be shown

update associated test files
pull/1388/head
Arthur Campbell 3 years ago
parent
commit
64b97ab12c
  1. 7
      app/models/form/sales/pages/nationality1.rb
  2. 10
      app/models/form/sales/questions/nationality1.rb
  3. 4
      app/models/sales_log.rb
  4. 12
      spec/models/form/sales/pages/nationality1_spec.rb
  5. 30
      spec/models/form/sales/questions/nationality1_spec.rb

7
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

10
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" => {

4
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

12
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

30
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

Loading…
Cancel
Save