Browse Source

Remove unconfirmed changes

pull/1356/head
Kat 3 years ago
parent
commit
30170ffc48
  1. 1
      app/models/form/sales/pages/mortgage_length.rb
  2. 14
      app/models/form/sales/questions/buyer1_previous_tenure.rb
  3. 4
      app/models/form/sales/questions/mortgage_length.rb
  4. 28
      app/models/form/sales/questions/mortgage_length_known.rb
  5. 2
      app/services/imports/sales_logs_import_service.rb
  6. 5
      db/migrate/20230228112317_add_mortgage_length_known.rb
  7. 7
      db/schema.rb
  8. 1
      spec/factories/sales_log.rb
  9. 2
      spec/models/form/sales/pages/mortgage_length_spec.rb
  10. 14
      spec/models/form/sales/questions/buyer1_previous_tenure_spec.rb
  11. 57
      spec/models/form/sales/questions/mortgage_length_known_spec.rb

1
app/models/form/sales/pages/mortgage_length.rb

@ -8,7 +8,6 @@ class Form::Sales::Pages::MortgageLength < ::Form::Page
def questions
@questions ||= [
Form::Sales::Questions::MortgageLengthKnown.new(nil, nil, self),
Form::Sales::Questions::MortgageLength.new(nil, nil, self),
]
end

14
app/models/form/sales/questions/buyer1_previous_tenure.rb

@ -17,19 +17,5 @@ class Form::Sales::Questions::Buyer1PreviousTenure < ::Form::Question
"6" => { "value" => "Living with family or friends" },
"7" => { "value" => "Temporary accomodation" },
"9" => { "value" => "Other" },
"0" => { "value" => "Don’t know" },
}.freeze
def displayed_answer_options(_log, _user = nil)
{
"1" => { "value" => "Local Authority" },
"2" => { "value" => "Private registered provider or housing association tenant" },
"3" => { "value" => "Private tenant" },
"5" => { "value" => "Owner occupier" },
"4" => { "value" => "Tied home or renting with job" },
"6" => { "value" => "Living with family or friends" },
"7" => { "value" => "Temporary accomodation" },
"9" => { "value" => "Other" },
}
end
end

4
app/models/form/sales/questions/mortgage_length.rb

@ -10,9 +10,5 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question
@width = 5
@suffix = " years"
@hint_text = "You should round up to the nearest year. Value should not exceed 60 years."
@inferred_check_answers_value = [{
"condition" => { "mortlen_known" => 2 },
"value" => "Not known",
}]
end
end

28
app/models/form/sales/questions/mortgage_length_known.rb

@ -1,28 +0,0 @@
class Form::Sales::Questions::MortgageLengthKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "mortlen_known"
@check_answer_label = "Mortgage length known"
@header = "Do you know the mortgage length?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@conditional_for = {
"mortlen" => [0],
}
@hidden_in_check_answers = {
"depends_on" => [
{
"mortlen_known" => 1,
},
{
"mortlen_known" => 2,
},
],
}
end
ANSWER_OPTIONS = {
"1" => { "value" => "Yes" },
"2" => { "value" => "No" },
}.freeze
end

2
app/services/imports/sales_logs_import_service.rb

@ -118,7 +118,6 @@ module Imports
attributes["mortgagelender"] = mortgage_lender(xml_doc, attributes)
attributes["mortgagelenderother"] = mortgage_lender_other(xml_doc, attributes)
attributes["mortlen"] = mortgage_length(xml_doc, attributes)
attributes["mortlen_known"] = 1 if attributes["mortlen"].present?
attributes["extrabor"] = borrowing(xml_doc, attributes)
attributes["totadult"] = safe_string_as_integer(xml_doc, "TOTADULT") # would get overridden
attributes["totchild"] = safe_string_as_integer(xml_doc, "TOTCHILD") # would get overridden
@ -405,7 +404,6 @@ module Imports
attributes["hb"] ||= 4
attributes["prevown"] ||= 3
attributes["savingsnk"] ||= attributes["savings"].present? ? 0 : 1
attributes["mortlen_known"] ||= 2 if attributes["mortgage"].blank?
# attributes["noint"] = 1 # not interviewed
# buyer 1 characteristics

5
db/migrate/20230228112317_add_mortgage_length_known.rb

@ -1,5 +0,0 @@
class AddMortgageLengthKnown < ActiveRecord::Migration[7.0]
def change
add_column :sales_logs, :mortlen_known, :integer
end
end

7
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: 2023_02_28_112317) do
ActiveRecord::Schema[7.0].define(version: 2023_02_15_112932) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -490,6 +490,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_28_112317) do
t.integer "prevten"
t.integer "mortgageused"
t.integer "wchair"
t.integer "income2_value_check"
t.integer "armedforcesspouse"
t.datetime "hodate", precision: nil
t.integer "hoday"
@ -525,13 +526,11 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_28_112317) do
t.integer "details_known_5"
t.integer "details_known_6"
t.integer "ethnic_group2"
t.integer "proplen_asked"
t.integer "ethnicbuy2"
t.integer "prevshared"
t.integer "staircasesale"
t.string "old_id"
t.integer "income2_value_check"
t.integer "proplen_asked"
t.integer "mortlen_known"
t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["old_id"], name: "index_sales_logs_on_old_id", unique: true

1
spec/factories/sales_log.rb

@ -95,7 +95,6 @@ FactoryBot.define do
armedforcesspouse { 5 }
mscharge_known { 1 }
mscharge { 100 }
mortlen_known { 1 }
mortlen { 10 }
pcodenk { 1 }
is_la_inferred { false }

2
spec/models/form/sales/pages/mortgage_length_spec.rb

@ -12,7 +12,7 @@ RSpec.describe Form::Sales::Pages::MortgageLength, type: :model do
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[mortlen_known mortlen])
expect(page.questions.map(&:id)).to eq(%w[mortlen])
end
it "has the correct id" do

14
spec/models/form/sales/questions/buyer1_previous_tenure_spec.rb

@ -42,20 +42,6 @@ RSpec.describe Form::Sales::Questions::Buyer1PreviousTenure, type: :model do
"6" => { "value" => "Living with family or friends" },
"7" => { "value" => "Temporary accomodation" },
"9" => { "value" => "Other" },
"0" => { "value" => "Don’t know" },
})
end
it "has the correct displayed_answer_options" do
expect(question.displayed_answer_options(log)).to eq({
"1" => { "value" => "Local Authority" },
"2" => { "value" => "Private registered provider or housing association tenant" },
"3" => { "value" => "Private tenant" },
"4" => { "value" => "Tied home or renting with job" },
"5" => { "value" => "Owner occupier" },
"6" => { "value" => "Living with family or friends" },
"7" => { "value" => "Temporary accomodation" },
"9" => { "value" => "Other" },
})
end
end

57
spec/models/form/sales/questions/mortgage_length_known_spec.rb

@ -1,57 +0,0 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::MortgageLengthKnown, 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("mortlen_known")
end
it "has the correct header" do
expect(question.header).to eq("Do you know the mortgage length?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Mortgage length known")
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 answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Yes" },
"2" => { "value" => "No" },
})
end
it "has correct conditional for" do
expect(question.conditional_for).to eq({
"mortlen" => [0],
})
end
it "has correct hidden in check answers" do
expect(question.hidden_in_check_answers).to eq({
"depends_on" => [{
"mortlen_known" => 1,
},
{
"mortlen_known" => 2,
}],
})
end
end
Loading…
Cancel
Save