From 1c6da76ce1451b4cb2a65ececd08ae49a083ca67 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 27 Sep 2022 09:13:27 +0100 Subject: [PATCH 01/13] Add nationality and other nationality questions --- .../form/sales/questions/nationality1.rb | 23 ++++++++ .../sales/questions/other_nationality1.rb | 10 ++++ .../form/sales/questions/nationality1_spec.rb | 53 +++++++++++++++++++ .../questions/other_nationality1_spec.rb | 37 +++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 app/models/form/sales/questions/nationality1.rb create mode 100644 app/models/form/sales/questions/other_nationality1.rb create mode 100644 spec/models/form/sales/questions/nationality1_spec.rb create mode 100644 spec/models/form/sales/questions/other_nationality1_spec.rb diff --git a/app/models/form/sales/questions/nationality1.rb b/app/models/form/sales/questions/nationality1.rb new file mode 100644 index 000000000..919230582 --- /dev/null +++ b/app/models/form/sales/questions/nationality1.rb @@ -0,0 +1,23 @@ +class Form::Sales::Questions::Nationality1 < ::Form::Question + def initialize(id, hsh, page) + super + @id = "national" + @check_answer_label = "Buyer 1’s nationality" + @header = "What is buyer 1’s nationality?" + @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." + @page = page + @answer_options = ANSWER_OPTIONS + @conditional_for = { + "othernational" => [12], + } + end + + ANSWER_OPTIONS = { + "18" => { "value" => "United Kingdom" }, + "17" => { "value" => "Republic of Ireland" }, + "19" => { "value" => "European Economic Area (EEA), excluding ROI" }, + "12" => { "value" => "Other " }, + "13" => { "value" => "Buyer prefers not to say " }, + }.freeze +end diff --git a/app/models/form/sales/questions/other_nationality1.rb b/app/models/form/sales/questions/other_nationality1.rb new file mode 100644 index 000000000..a779d4fc8 --- /dev/null +++ b/app/models/form/sales/questions/other_nationality1.rb @@ -0,0 +1,10 @@ +class Form::Sales::Questions::OtherNationality1 < ::Form::Question + def initialize(id, hsh, page) + super + @id = "othernational" + @check_answer_label = "Buyer 1’s nationality" + @header = "Nationality" + @type = "text" + @page = page + end +end diff --git a/spec/models/form/sales/questions/nationality1_spec.rb b/spec/models/form/sales/questions/nationality1_spec.rb new file mode 100644 index 000000000..118c22f5f --- /dev/null +++ b/spec/models/form/sales/questions/nationality1_spec.rb @@ -0,0 +1,53 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::Nationality1, type: :model do + subject(:question) { described_class.new(question_id, question_definition, 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) + end + + it "has the correct id" do + expect(question.id).to eq("national") + end + + it "has the correct header" do + 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") + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + 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.") + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "18" => { "value" => "United Kingdom" }, + "17" => { "value" => "Republic of Ireland" }, + "19" => { "value" => "European Economic Area (EEA), excluding ROI" }, + "12" => { "value" => "Other " }, + "13" => { "value" => "Buyer prefers not to say " }, + }) + end + + it "has correct conditional for" do + expect(question.conditional_for).to eq({ + "othernational" => [12], + }) + end +end diff --git a/spec/models/form/sales/questions/other_nationality1_spec.rb b/spec/models/form/sales/questions/other_nationality1_spec.rb new file mode 100644 index 000000000..b01928efc --- /dev/null +++ b/spec/models/form/sales/questions/other_nationality1_spec.rb @@ -0,0 +1,37 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::OtherNationality1, type: :model do + subject(:question) { described_class.new(question_id, question_definition, 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) + end + + it "has the correct id" do + expect(question.id).to eq("othernational") + end + + it "has the correct header" do + expect(question.header).to eq("Nationality") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer 1’s nationality") + end + + it "has the correct type" do + expect(question.type).to eq("text") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end +end From 994a047d3549f7c2c06139d513ba8801d2ef034b Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 27 Sep 2022 09:25:53 +0100 Subject: [PATCH 02/13] Add nationality page --- app/models/form/sales/pages/nationality1.rb | 16 +++++++++ .../subsections/household_characteristics.rb | 1 + .../form/sales/pages/nationality1_spec.rb | 33 +++++++++++++++++++ .../household_characteristics_spec.rb | 1 + 4 files changed, 51 insertions(+) create mode 100644 app/models/form/sales/pages/nationality1.rb create mode 100644 spec/models/form/sales/pages/nationality1_spec.rb diff --git a/app/models/form/sales/pages/nationality1.rb b/app/models/form/sales/pages/nationality1.rb new file mode 100644 index 000000000..740aa694f --- /dev/null +++ b/app/models/form/sales/pages/nationality1.rb @@ -0,0 +1,16 @@ +class Form::Sales::Pages::Nationality1 < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "buyer_1_nationality" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::Nationality1.new(nil, nil, self), + Form::Sales::Questions::OtherNationality1.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index 219547067..3bfd4d10e 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -11,6 +11,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection @pages ||= [ Form::Sales::Pages::Age1.new(nil, nil, self), Form::Sales::Pages::GenderIdentity1.new(nil, nil, self), + Form::Sales::Pages::Nationality1.new(nil, nil, self), Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicGroup.new(nil, nil, self), diff --git a/spec/models/form/sales/pages/nationality1_spec.rb b/spec/models/form/sales/pages/nationality1_spec.rb new file mode 100644 index 000000000..5d156e041 --- /dev/null +++ b/spec/models/form/sales/pages/nationality1_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Nationality1, type: :model do + subject(:page) { described_class.new(page_id, page_definition, 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) + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[national othernational]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_1_nationality") + end + + it "has the correct header" do + expect(page.header).to eq("") + end + + it "has the correct description" do + expect(page.description).to eq("") + end + + it "has correct depends_on" do + expect(page.depends_on).to be_nil + end +end diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index cde59cfd5..6460e1fa9 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -24,6 +24,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model buyer_1_ethnic_background_arab buyer_1_ethnic_background_mixed buyer_1_ethnic_background_white + buyer_1_nationality buyer_2_age ], ) From ccacc956f69e6bc0c67c4684b227870190a6839f Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 27 Sep 2022 09:26:43 +0100 Subject: [PATCH 03/13] Add national columns --- db/migrate/20220927082602_add_national_column.rb | 8 ++++++++ db/schema.rb | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 db/migrate/20220927082602_add_national_column.rb diff --git a/db/migrate/20220927082602_add_national_column.rb b/db/migrate/20220927082602_add_national_column.rb new file mode 100644 index 000000000..d794bc858 --- /dev/null +++ b/db/migrate/20220927082602_add_national_column.rb @@ -0,0 +1,8 @@ +class AddNationalColumn < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :national, :integer + t.column :othernational, :string + end + end +end diff --git a/db/schema.rb b/db/schema.rb index f8dbff468..12dcb1e74 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -347,6 +347,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_29_125204) do t.integer "age2_known" t.integer "ethnic" t.integer "ethnic_group" + t.integer "national" + t.string "othernational" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" From 0a64b474a930754a9211e9b0528567c1b13e29d6 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 27 Sep 2022 11:03:59 +0100 Subject: [PATCH 04/13] Add hidden_in_check_answers --- app/models/form/sales/questions/nationality1.rb | 11 +++++++++-- spec/models/form/sales/questions/nationality1_spec.rb | 10 ++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/models/form/sales/questions/nationality1.rb b/app/models/form/sales/questions/nationality1.rb index 919230582..737bfc01e 100644 --- a/app/models/form/sales/questions/nationality1.rb +++ b/app/models/form/sales/questions/nationality1.rb @@ -11,13 +11,20 @@ class Form::Sales::Questions::Nationality1 < ::Form::Question @conditional_for = { "othernational" => [12], } + @hidden_in_check_answers = { + "depends_on" => [ + { + "national" => 12, + }, + ], + } end ANSWER_OPTIONS = { "18" => { "value" => "United Kingdom" }, "17" => { "value" => "Republic of Ireland" }, "19" => { "value" => "European Economic Area (EEA), excluding ROI" }, - "12" => { "value" => "Other " }, - "13" => { "value" => "Buyer prefers not to say " }, + "12" => { "value" => "Other" }, + "13" => { "value" => "Buyer prefers not to say" }, }.freeze end diff --git a/spec/models/form/sales/questions/nationality1_spec.rb b/spec/models/form/sales/questions/nationality1_spec.rb index 118c22f5f..e3d8f832b 100644 --- a/spec/models/form/sales/questions/nationality1_spec.rb +++ b/spec/models/form/sales/questions/nationality1_spec.rb @@ -50,4 +50,14 @@ RSpec.describe Form::Sales::Questions::Nationality1, type: :model do "othernational" => [12], }) end + + it "has correct hidden in check answers" do + expect(question.hidden_in_check_answers).to eq({ + "depends_on" => [ + { + "national" => 12, + }, + ], + }) + end end From b7568c69c081e8bbd26e2535e4dbd0358aa616bb Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 27 Sep 2022 13:37:37 +0100 Subject: [PATCH 05/13] Update conditional question controller to work with both log types --- .../conditional_question_controller.js | 11 ++++++++--- app/helpers/question_attribute_helper.rb | 2 +- .../form/conditional_questions_spec.rb | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/frontend/controllers/conditional_question_controller.js b/app/frontend/controllers/conditional_question_controller.js index 974deeb2e..f84f6a7d8 100644 --- a/app/frontend/controllers/conditional_question_controller.js +++ b/app/frontend/controllers/conditional_question_controller.js @@ -7,15 +7,20 @@ export default class extends Controller { displayConditional () { if (this.element.checked) { + console.log(this.element) + const selectedValue = this.element.value - const conditionalFor = JSON.parse(this.element.dataset.info) + + const dataInfo = JSON.parse(this.element.dataset.info) + const conditionalFor = dataInfo.conditional_questions + const logType = dataInfo.log_type Object.entries(conditionalFor).forEach(([targetQuestion, conditions]) => { if (!conditions.map(String).includes(String(selectedValue))) { - const textNumericInput = document.getElementById(`lettings-log-${targetQuestion.replaceAll('_', '-')}-field`) + const textNumericInput = document.getElementById(`${logType}-log-${targetQuestion.replaceAll('_', '-')}-field`) if (textNumericInput == null) { const dateInputs = [1, 2, 3].map((idx) => { - return document.getElementById(`lettings_log_${targetQuestion}_${idx}i`) + return document.getElementById(`${logType}_log_${targetQuestion}_${idx}i`) }) this.clearDateInputs(dateInputs) } else { diff --git a/app/helpers/question_attribute_helper.rb b/app/helpers/question_attribute_helper.rb index f2f148568..857ce5eb1 100644 --- a/app/helpers/question_attribute_helper.rb +++ b/app/helpers/question_attribute_helper.rb @@ -27,7 +27,7 @@ private { "data-controller": "conditional-question", "data-action": "click->conditional-question#displayConditional", - "data-info": question.conditional_for.to_json, + "data-info": { conditional_questions: question.conditional_for, log_type: question.form.type }.to_json, } end end diff --git a/spec/features/form/conditional_questions_spec.rb b/spec/features/form/conditional_questions_spec.rb index 4f3f44b5a..e68cdf098 100644 --- a/spec/features/form/conditional_questions_spec.rb +++ b/spec/features/form/conditional_questions_spec.rb @@ -12,6 +12,14 @@ RSpec.describe "Form Conditional Questions" do managing_organisation: user.organisation, ) end + let(:sales_log) do + FactoryBot.create( + :sales_log, + :completed, + owning_organisation: user.organisation, + managing_organisation: user.organisation, + ) + end let(:id) { lettings_log.id } let(:fake_2021_2022_form) { Form.new("spec/fixtures/forms/2021_2022.json") } @@ -44,5 +52,15 @@ RSpec.describe "Form Conditional Questions" do visit("/lettings-logs/#{id}/property-postcode") expect(page).to have_field("lettings-log-postcode-full-field", with: "NW1 6RT") end + + it "gets cleared if the conditinoal question is hidden after editing the answer" do + sales_log.update!(national: 12, othernational: "other") + visit("/sales-logs/#{sales_log.id}/buyer-1-nationality") + expect(page).to have_field("sales-log-othernational-field", with: "other") + + choose("sales-log-national-18-field", allow_label_click: true) + choose("sales-log-national-12-field", allow_label_click: true) + expect(page).to have_field("sales-log-othernational-field", with: "") + end end end From 49e2ca7177a0912ac71c4951685d0a9c0561e883 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 27 Sep 2022 13:56:06 +0100 Subject: [PATCH 06/13] update tests --- db/schema.rb | 1 + spec/factories/sales_log.rb | 1 + spec/helpers/question_attribute_helper_spec.rb | 4 ++-- spec/models/form/sales/questions/nationality1_spec.rb | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 12dcb1e74..00ad8c2de 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -349,6 +349,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_29_125204) do t.integer "ethnic_group" t.integer "national" t.string "othernational" + t.integer "buy1livein" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb index 987f69e2c..3b975c055 100644 --- a/spec/factories/sales_log.rb +++ b/spec/factories/sales_log.rb @@ -23,6 +23,7 @@ FactoryBot.define do age1_known { 0 } age1 { 30 } sex1 { "X" } + national { 18 } buy1livein { 1 } relat2 { "P" } proptype { 1 } diff --git a/spec/helpers/question_attribute_helper_spec.rb b/spec/helpers/question_attribute_helper_spec.rb index 96f2f7ef6..a007ec647 100644 --- a/spec/helpers/question_attribute_helper_spec.rb +++ b/spec/helpers/question_attribute_helper_spec.rb @@ -40,7 +40,7 @@ RSpec.describe QuestionAttributeHelper do "conditional_for" => { "next_question": ">1", }, - }, nil) + }, form.get_page("rent")) end let(:expected_attribs) do { @@ -48,7 +48,7 @@ RSpec.describe QuestionAttributeHelper do "data-action": "input->numeric-question#calculateFields click->conditional-question#displayConditional", "data-target": "lettings-log-#{question.result_field.to_s.dasherize}-field", "data-calculated": question.fields_to_add.to_json, - "data-info": question.conditional_for.to_json, + "data-info": { conditional_questions: question.conditional_for, log_type: "lettings" }.to_json } end diff --git a/spec/models/form/sales/questions/nationality1_spec.rb b/spec/models/form/sales/questions/nationality1_spec.rb index e3d8f832b..819d41ae4 100644 --- a/spec/models/form/sales/questions/nationality1_spec.rb +++ b/spec/models/form/sales/questions/nationality1_spec.rb @@ -40,8 +40,8 @@ RSpec.describe Form::Sales::Questions::Nationality1, type: :model do "18" => { "value" => "United Kingdom" }, "17" => { "value" => "Republic of Ireland" }, "19" => { "value" => "European Economic Area (EEA), excluding ROI" }, - "12" => { "value" => "Other " }, - "13" => { "value" => "Buyer prefers not to say " }, + "12" => { "value" => "Other" }, + "13" => { "value" => "Buyer prefers not to say" }, }) end From 946904acd6a23d214945bc287895db437f2b476d Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 27 Sep 2022 13:59:10 +0100 Subject: [PATCH 07/13] lint --- spec/helpers/question_attribute_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/helpers/question_attribute_helper_spec.rb b/spec/helpers/question_attribute_helper_spec.rb index a007ec647..2be903535 100644 --- a/spec/helpers/question_attribute_helper_spec.rb +++ b/spec/helpers/question_attribute_helper_spec.rb @@ -48,7 +48,7 @@ RSpec.describe QuestionAttributeHelper do "data-action": "input->numeric-question#calculateFields click->conditional-question#displayConditional", "data-target": "lettings-log-#{question.result_field.to_s.dasherize}-field", "data-calculated": question.fields_to_add.to_json, - "data-info": { conditional_questions: question.conditional_for, log_type: "lettings" }.to_json + "data-info": { conditional_questions: question.conditional_for, log_type: "lettings" }.to_json, } end From 19247e10f80d5ed7208088b0b94b65837a760775 Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 28 Sep 2022 09:09:22 +0100 Subject: [PATCH 08/13] Remove console.log --- app/frontend/controllers/conditional_question_controller.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/frontend/controllers/conditional_question_controller.js b/app/frontend/controllers/conditional_question_controller.js index f84f6a7d8..fb52d07c1 100644 --- a/app/frontend/controllers/conditional_question_controller.js +++ b/app/frontend/controllers/conditional_question_controller.js @@ -7,10 +7,7 @@ export default class extends Controller { displayConditional () { if (this.element.checked) { - console.log(this.element) - const selectedValue = this.element.value - const dataInfo = JSON.parse(this.element.dataset.info) const conditionalFor = dataInfo.conditional_questions const logType = dataInfo.log_type From 0ed1f0062eefc7e1edb822430fb4097863d89f2a Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 28 Sep 2022 09:57:34 +0100 Subject: [PATCH 09/13] tests and migration --- db/schema.rb | 8 +++++--- spec/models/form_handler_spec.rb | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 00ad8c2de..13ecf8f93 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -329,15 +329,17 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_29_125204) do t.string "purchid" t.integer "type" t.integer "ownershipsch" - t.string "othtype" - t.integer "jointmore" t.integer "jointpur" + t.string "othtype" t.integer "beds" - t.integer "companybuy" + t.integer "jointmore" t.integer "age1" t.integer "age1_known" t.string "sex1" + t.integer "national" + t.string "othernational" t.integer "buy1livein" + t.integer "companybuy" t.integer "buylivein" t.integer "builtype" t.integer "proptype" diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index cb9258803..12b7c214b 100644 --- a/spec/models/form_handler_spec.rb +++ b/spec/models/form_handler_spec.rb @@ -61,14 +61,14 @@ RSpec.describe FormHandler do it "is able to load a current sales form" do form = form_handler.get_form("current_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(26) + expect(form.pages.count).to eq(27) expect(form.name).to eq("2022_2023_sales") end it "is able to load a previous sales form" do form = form_handler.get_form("previous_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(26) + expect(form.pages.count).to eq(27) expect(form.name).to eq("2021_2022_sales") end end From 90563c4d8e85a4e8a6c7357090b89a6969acb495 Mon Sep 17 00:00:00 2001 From: Kat Date: Fri, 30 Sep 2022 09:55:04 +0100 Subject: [PATCH 10/13] typo --- spec/features/form/conditional_questions_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/form/conditional_questions_spec.rb b/spec/features/form/conditional_questions_spec.rb index e68cdf098..33d99955e 100644 --- a/spec/features/form/conditional_questions_spec.rb +++ b/spec/features/form/conditional_questions_spec.rb @@ -53,7 +53,7 @@ RSpec.describe "Form Conditional Questions" do expect(page).to have_field("lettings-log-postcode-full-field", with: "NW1 6RT") end - it "gets cleared if the conditinoal question is hidden after editing the answer" do + it "gets cleared if the conditional question is hidden after editing the answer" do sales_log.update!(national: 12, othernational: "other") visit("/sales-logs/#{sales_log.id}/buyer-1-nationality") expect(page).to have_field("sales-log-othernational-field", with: "other") From 009d50d1d8cae65c26cd236b9623465bf8a7d02a Mon Sep 17 00:00:00 2001 From: Kat Date: Fri, 30 Sep 2022 15:55:47 +0100 Subject: [PATCH 11/13] tests --- db/schema.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 13ecf8f93..d25675cbc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -343,8 +343,6 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_29_125204) do t.integer "buylivein" t.integer "builtype" t.integer "proptype" - t.string "relat2" - t.string "otherrelat2" t.integer "age2" t.integer "age2_known" t.integer "ethnic" @@ -352,6 +350,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_29_125204) do t.integer "national" t.string "othernational" t.integer "buy1livein" + t.string "relat2" + t.string "otherrelat2" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" From cd0a2e6d9bf7f42eb7d376648c8f03a979d91c20 Mon Sep 17 00:00:00 2001 From: Kat Date: Fri, 30 Sep 2022 16:27:44 +0100 Subject: [PATCH 12/13] tests --- db/schema.rb | 7 ++----- .../sales/subsections/household_characteristics_spec.rb | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index d25675cbc..b8e0da05e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -345,13 +345,10 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_29_125204) do t.integer "proptype" t.integer "age2" t.integer "age2_known" - t.integer "ethnic" - t.integer "ethnic_group" - t.integer "national" - t.string "othernational" - t.integer "buy1livein" t.string "relat2" t.string "otherrelat2" + t.integer "ethnic" + t.integer "ethnic_group" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 6460e1fa9..e2e8e0a90 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -16,6 +16,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model %w[ buyer_1_age buyer_1_gender_identity + buyer_1_nationality buyer_1_live_in_property buyer_2_relationship_to_buyer_1 buyer_1_ethnic_group @@ -24,7 +25,6 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model buyer_1_ethnic_background_arab buyer_1_ethnic_background_mixed buyer_1_ethnic_background_white - buyer_1_nationality buyer_2_age ], ) From f48d5bac1cbc11807b6e6c480b40b9c25b7a915a Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 5 Oct 2022 09:36:54 +0100 Subject: [PATCH 13/13] feat: update schema and tests --- .../form/sales/subsections/household_characteristics.rb | 6 +++--- db/schema.rb | 2 +- .../sales/subsections/household_characteristics_spec.rb | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index afd1643c1..e389d5e72 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -12,15 +12,15 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::BuyerInterview.new(nil, nil, self), Form::Sales::Pages::Age1.new(nil, nil, self), Form::Sales::Pages::GenderIdentity1.new(nil, nil, self), - Form::Sales::Pages::Nationality1.new(nil, nil, self), - Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), - Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicGroup.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicBackgroundBlack.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicBackgroundAsian.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicBackgroundArab.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicBackgroundMixed.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicBackgroundWhite.new(nil, nil, self), + Form::Sales::Pages::Nationality1.new(nil, nil, self), + Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), + Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self), Form::Sales::Pages::Age2.new(nil, nil, self), Form::Sales::Pages::GenderIdentity2.new(nil, nil, self), Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self), diff --git a/db/schema.rb b/db/schema.rb index 8baa195e7..269091a77 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_10_03_150610) do +ActiveRecord::Schema[7.0].define(version: 2022_10_04_095132) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 575c3d44f..21e496efd 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -17,15 +17,15 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model buyer_interview buyer_1_age buyer_1_gender_identity - buyer_1_nationality - buyer_1_live_in_property - buyer_2_relationship_to_buyer_1 buyer_1_ethnic_group buyer_1_ethnic_background_black buyer_1_ethnic_background_asian buyer_1_ethnic_background_arab buyer_1_ethnic_background_mixed buyer_1_ethnic_background_white + buyer_1_nationality + buyer_1_live_in_property + buyer_2_relationship_to_buyer_1 buyer_2_age buyer_2_gender_identity buyer_2_working_situation