Browse Source

Cldc 1576 buyer prp (#1117)

* Add soctenant field to sales logs

* Add buyer previous page and question

* Add buyer previous page to shared ownership scheme subsection

* rebase migrate

* rebase too
pull/1130/head
kosiakkatrina 4 years ago committed by Kat
parent
commit
998da0050c
  1. 15
      app/models/form/sales/pages/buyer_previous.rb
  2. 16
      app/models/form/sales/questions/buyer_previous.rb
  3. 1
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  4. 7
      db/migrate/20221222120105_add_soctenant.rb
  5. 5
      db/schema.rb
  6. 29
      spec/models/form/sales/pages/buyer_previous_spec.rb
  7. 48
      spec/models/form/sales/questions/buyer_previous_spec.rb
  8. 1
      spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb
  9. 4
      spec/models/form_handler_spec.rb

15
app/models/form/sales/pages/buyer_previous.rb

@ -0,0 +1,15 @@
class Form::Sales::Pages::BuyerPrevious < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_previous"
@header = ""
@description = ""
@subsection = subsection
end
def questions
@questions ||= [
Form::Sales::Questions::BuyerPrevious.new(nil, nil, self),
]
end
end

16
app/models/form/sales/questions/buyer_previous.rb

@ -0,0 +1,16 @@
class Form::Sales::Questions::BuyerPrevious < ::Form::Question
def initialize(id, hsh, page)
super
@id = "soctenant"
@check_answer_label = "Buyer was a registered provider, housing association or local authority tenant immediately before this sale?"
@header = "Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@page = page
end
ANSWER_OPTIONS = {
"1" => { "value" => "Yes" },
"2" => { "value" => "No" },
}.freeze
end

1
app/models/form/sales/subsections/shared_ownership_scheme.rb

@ -13,6 +13,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::AboutStaircase.new(nil, nil, self),
Form::Sales::Pages::Resale.new(nil, nil, self),
Form::Sales::Pages::LaNominations.new(nil, nil, self),
Form::Sales::Pages::BuyerPrevious.new(nil, nil, self),
Form::Sales::Pages::PreviousBedrooms.new(nil, nil, self),
Form::Sales::Pages::AboutDeposit.new("about_deposit_shared_ownership", nil, self),
Form::Sales::Pages::MonthlyRent.new(nil, nil, self),

7
db/migrate/20221222120105_add_soctenant.rb

@ -0,0 +1,7 @@
class AddSoctenant < ActiveRecord::Migration[7.0]
def change
change_table :sales_logs, bulk: true do |t|
t.column :soctenant, :integer
end
end
end

5
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_12_21_172821) do
ActiveRecord::Schema[7.0].define(version: 2022_12_22_133600) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -405,12 +405,12 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_21_172821) do
t.integer "savings"
t.integer "prevown"
t.string "sex3"
t.bigint "updated_by_id"
t.integer "details_known_1"
t.integer "income1_value_check"
t.integer "mortgage"
t.integer "inc2mort"
t.integer "mortgage_value_check"
t.bigint "updated_by_id"
t.integer "ecstat3"
t.integer "ecstat4"
t.integer "ecstat5"
@ -429,6 +429,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_21_172821) do
t.decimal "deposit", precision: 10, scale: 2
t.decimal "cashdis", precision: 10, scale: 2
t.integer "lanomagr"
t.integer "soctenant"
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"

29
spec/models/form/sales/pages/buyer_previous_spec.rb

@ -0,0 +1,29 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::BuyerPrevious, 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[soctenant])
end
it "has the correct id" do
expect(page.id).to eq("buyer_previous")
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
end

48
spec/models/form/sales/questions/buyer_previous_spec.rb

@ -0,0 +1,48 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::BuyerPrevious, 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("soctenant")
end
it "has the correct header" do
expect(question.header).to eq("Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyer was a registered provider, housing association or local authority tenant immediately before this sale?")
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(nil)
end
it "has the correct hint" do
expect(question.hint_text).to eq(nil)
end
end

1
spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb

@ -18,6 +18,7 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do
about_staircasing
resale
la_nominations
buyer_previous
previous_bedrooms
about_deposit_shared_ownership
monthly_rent

4
spec/models/form_handler_spec.rb

@ -52,14 +52,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(78)
expect(form.pages.count).to eq(79)
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(78)
expect(form.pages.count).to eq(79)
expect(form.name).to eq("2021_2022_sales")
end
end

Loading…
Cancel
Save