Browse Source
* feat: add question(s) without depends_on behaviour * feat: separate ids for diff sections * test: update tests * test: add tests * tests: test tweaks * refactor: linting * Cldc 1538 la nominations (#1115) * Add la nominations column to sales logs table * Add La nominations page and questions * Add la nominations to the shared ownership subsection * Add accidentally removed files * feat: add question(s) without depends_on behaviour Co-authored-by: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>pull/1116/head
natdeanlewissoftwire
2 years ago
committed by
GitHub
16 changed files with 199 additions and 7 deletions
@ -0,0 +1,15 @@
|
||||
class Form::Sales::Pages::AboutDeposit < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@header = "About the deposit" |
||||
@description = "" |
||||
@subsection = subsection |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::DepositAmount.new(nil, nil, self), |
||||
Form::Sales::Questions::DepositDiscount.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -0,0 +1,14 @@
|
||||
class Form::Sales::Questions::DepositAmount < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "deposit" |
||||
@check_answer_label = "Cash deposit" |
||||
@header = "How much cash deposit was paid on the property?" |
||||
@type = "numeric" |
||||
@page = page |
||||
@min = 0 |
||||
@width = 5 |
||||
@prefix = "£" |
||||
@hint_text = "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage" |
||||
end |
||||
end |
@ -0,0 +1,14 @@
|
||||
class Form::Sales::Questions::DepositDiscount < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "cashdis" |
||||
@check_answer_label = "Cash discount through SocialHomeBuy" |
||||
@header = "How much cash discount was given through Social HomeBuy?" |
||||
@type = "numeric" |
||||
@page = page |
||||
@min = 0 |
||||
@width = 5 |
||||
@prefix = "£" |
||||
@hint_text = "Enter the total cash discount given on the property being purchased through the Social HomeBuy scheme" |
||||
end |
||||
end |
@ -0,0 +1,8 @@
|
||||
class AddDepositFieldsToSales < ActiveRecord::Migration[7.0] |
||||
def change |
||||
change_table :sales_logs, bulk: true do |t| |
||||
t.column :deposit, :decimal, precision: 10, scale: 2 |
||||
t.column :cashdis, :decimal, precision: 10, scale: 2 |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,33 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::AboutDeposit, 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[deposit cashdis]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq(nil) |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("About the deposit") |
||||
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 |
@ -0,0 +1,49 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::DepositAmount, 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("deposit") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("How much cash deposit was paid on the property?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Cash deposit") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("numeric") |
||||
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("Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage") |
||||
end |
||||
|
||||
it "has correct width" do |
||||
expect(question.width).to eq(5) |
||||
end |
||||
|
||||
it "has correct prefix" do |
||||
expect(question.prefix).to eq("£") |
||||
end |
||||
|
||||
it "has correct min" do |
||||
expect(question.min).to eq(0) |
||||
end |
||||
end |
@ -0,0 +1,49 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::DepositDiscount, 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("cashdis") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("How much cash discount was given through Social HomeBuy?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Cash discount through SocialHomeBuy") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("numeric") |
||||
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("Enter the total cash discount given on the property being purchased through the Social HomeBuy scheme") |
||||
end |
||||
|
||||
it "has correct width" do |
||||
expect(question.width).to eq(5) |
||||
end |
||||
|
||||
it "has correct prefix" do |
||||
expect(question.prefix).to eq("£") |
||||
end |
||||
|
||||
it "has correct min" do |
||||
expect(question.min).to eq(0) |
||||
end |
||||
end |
Loading…
Reference in new issue