Kat
2 years ago
7 changed files with 237 additions and 0 deletions
@ -0,0 +1,17 @@
|
||||
class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection |
||||
def initialize(id, hsh, section) |
||||
super |
||||
@id = "discounted_ownership_scheme" |
||||
@label = "Discounted ownership scheme" |
||||
@section = section |
||||
@depends_on = [{ "ownershipsch" => 2, "setup_completed?" => true }] |
||||
end |
||||
|
||||
def pages |
||||
@pages ||= [] |
||||
end |
||||
|
||||
def displayed_in_tasklist?(log) |
||||
log.ownershipsch == 2 |
||||
end |
||||
end |
@ -0,0 +1,17 @@
|
||||
class Form::Sales::Subsections::OutrightSale < ::Form::Subsection |
||||
def initialize(id, hsh, section) |
||||
super |
||||
@id = "outright_sale" |
||||
@label = "Outright sale" |
||||
@section = section |
||||
@depends_on = [{ "ownershipsch" => 3, "setup_completed?" => true }] |
||||
end |
||||
|
||||
def pages |
||||
@pages ||= [] |
||||
end |
||||
|
||||
def displayed_in_tasklist?(log) |
||||
log.ownershipsch == 3 |
||||
end |
||||
end |
@ -0,0 +1,17 @@
|
||||
class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection |
||||
def initialize(id, hsh, section) |
||||
super |
||||
@id = "shared_ownership_scheme" |
||||
@label = "Shared ownership scheme" |
||||
@section = section |
||||
@depends_on = [{ "ownershipsch" => 1, "setup_completed?" => true }] |
||||
end |
||||
|
||||
def pages |
||||
@pages ||= [] |
||||
end |
||||
|
||||
def displayed_in_tasklist?(log) |
||||
log.ownershipsch == 1 |
||||
end |
||||
end |
@ -0,0 +1,33 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Sections::SaleInformation, type: :model do |
||||
subject(:sale_information) { described_class.new(section_id, section_definition, form) } |
||||
|
||||
let(:section_id) { nil } |
||||
let(:section_definition) { nil } |
||||
let(:form) { instance_double(Form) } |
||||
|
||||
it "has correct form" do |
||||
expect(sale_information.form).to eq(form) |
||||
end |
||||
|
||||
it "has correct subsections" do |
||||
expect(sale_information.subsections.map(&:id)).to eq(%w[ |
||||
shared_ownership_scheme |
||||
discounted_ownership_scheme |
||||
outright_sale |
||||
]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(sale_information.id).to eq("sale_information") |
||||
end |
||||
|
||||
it "has the correct label" do |
||||
expect(sale_information.label).to eq("Sale information") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(sale_information.description).to eq("") |
||||
end |
||||
end |
@ -0,0 +1,51 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model do |
||||
subject(:discounted_ownership_scheme) { described_class.new(subsection_id, subsection_definition, section) } |
||||
|
||||
let(:subsection_id) { nil } |
||||
let(:subsection_definition) { nil } |
||||
let(:section) { instance_double(Form::Sales::Sections::SaleInformation) } |
||||
|
||||
it "has correct section" do |
||||
expect(discounted_ownership_scheme.section).to eq(section) |
||||
end |
||||
|
||||
it "has correct pages" do |
||||
expect(discounted_ownership_scheme.pages.map(&:id)).to eq( |
||||
%w[], |
||||
) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(discounted_ownership_scheme.id).to eq("discounted_ownership_scheme") |
||||
end |
||||
|
||||
it "has the correct label" do |
||||
expect(discounted_ownership_scheme.label).to eq("Discounted ownership scheme") |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(discounted_ownership_scheme.depends_on).to eq([ |
||||
{ |
||||
"ownershipsch" => 2, "setup_completed?" => true |
||||
}, |
||||
]) |
||||
end |
||||
|
||||
context "when it is a discounted ownership scheme" do |
||||
let(:log) { FactoryBot.create(:sales_log, ownershipsch: 2) } |
||||
|
||||
it "is displayed in tasklist" do |
||||
expect(discounted_ownership_scheme.displayed_in_tasklist?(log)).to eq(true) |
||||
end |
||||
end |
||||
|
||||
context "when it is not a discounted ownership scheme" do |
||||
let(:log) { FactoryBot.create(:sales_log, ownershipsch: 1) } |
||||
|
||||
it "is displayed in tasklist" do |
||||
expect(discounted_ownership_scheme.displayed_in_tasklist?(log)).to eq(false) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,51 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do |
||||
subject(:outright_sale) { described_class.new(subsection_id, subsection_definition, section) } |
||||
|
||||
let(:subsection_id) { nil } |
||||
let(:subsection_definition) { nil } |
||||
let(:section) { instance_double(Form::Sales::Sections::SaleInformation) } |
||||
|
||||
it "has correct section" do |
||||
expect(outright_sale.section).to eq(section) |
||||
end |
||||
|
||||
it "has correct pages" do |
||||
expect(outright_sale.pages.map(&:id)).to eq( |
||||
%w[], |
||||
) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(outright_sale.id).to eq("outright_sale") |
||||
end |
||||
|
||||
it "has the correct label" do |
||||
expect(outright_sale.label).to eq("Outright sale") |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(outright_sale.depends_on).to eq([ |
||||
{ |
||||
"ownershipsch" => 3, "setup_completed?" => true |
||||
}, |
||||
]) |
||||
end |
||||
|
||||
context "when it is a outright sale" do |
||||
let(:log) { FactoryBot.create(:sales_log, ownershipsch: 3) } |
||||
|
||||
it "is displayed in tasklist" do |
||||
expect(outright_sale.displayed_in_tasklist?(log)).to eq(true) |
||||
end |
||||
end |
||||
|
||||
context "when it is not a outright sale" do |
||||
let(:log) { FactoryBot.create(:sales_log, ownershipsch: 2) } |
||||
|
||||
it "is displayed in tasklist" do |
||||
expect(outright_sale.displayed_in_tasklist?(log)).to eq(false) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,51 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do |
||||
subject(:shared_ownership_scheme) { described_class.new(subsection_id, subsection_definition, section) } |
||||
|
||||
let(:subsection_id) { nil } |
||||
let(:subsection_definition) { nil } |
||||
let(:section) { instance_double(Form::Sales::Sections::SaleInformation) } |
||||
|
||||
it "has correct section" do |
||||
expect(shared_ownership_scheme.section).to eq(section) |
||||
end |
||||
|
||||
it "has correct pages" do |
||||
expect(shared_ownership_scheme.pages.map(&:id)).to eq( |
||||
%w[], |
||||
) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(shared_ownership_scheme.id).to eq("shared_ownership_scheme") |
||||
end |
||||
|
||||
it "has the correct label" do |
||||
expect(shared_ownership_scheme.label).to eq("Shared ownership scheme") |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(shared_ownership_scheme.depends_on).to eq([ |
||||
{ |
||||
"ownershipsch" => 1, "setup_completed?" => true |
||||
}, |
||||
]) |
||||
end |
||||
|
||||
context "when it is a shared ownership scheme" do |
||||
let(:log) { FactoryBot.create(:sales_log, ownershipsch: 1) } |
||||
|
||||
it "is displayed in tasklist" do |
||||
expect(shared_ownership_scheme.displayed_in_tasklist?(log)).to eq(true) |
||||
end |
||||
end |
||||
|
||||
context "when it is not a shared ownership scheme" do |
||||
let(:log) { FactoryBot.create(:sales_log, ownershipsch: 2) } |
||||
|
||||
it "is displayed in tasklist" do |
||||
expect(shared_ownership_scheme.displayed_in_tasklist?(log)).to eq(false) |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue