Rachael Booth
2 months ago
committed by
GitHub
15 changed files with 55 additions and 252 deletions
@ -1,24 +0,0 @@ |
|||||||
class Form::Lettings::Pages::MaxRentValueCheck < ::Form::Page |
|
||||||
def initialize(id, hsh, subsection, check_answers_card_number: nil) |
|
||||||
super(id, hsh, subsection) |
|
||||||
@depends_on = [{ "rent_in_soft_max_range?" => true }] |
|
||||||
@title_text = { |
|
||||||
"translation" => "soft_validations.rent.outside_range_title", |
|
||||||
"arguments" => [{ |
|
||||||
"key" => "brent", |
|
||||||
"label" => true, |
|
||||||
"i18n_template" => "brent", |
|
||||||
}], |
|
||||||
} |
|
||||||
@informative_text = I18n.t("soft_validations.rent.informative_text", higher_or_lower: "higher") |
|
||||||
@check_answers_card_number = check_answers_card_number |
|
||||||
end |
|
||||||
|
|
||||||
def questions |
|
||||||
@questions ||= [Form::Lettings::Questions::MaxRentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)] |
|
||||||
end |
|
||||||
|
|
||||||
def interruption_screen_question_ids |
|
||||||
%w[brent period startdate uprn postcode_full la beds rent_type needstype] |
|
||||||
end |
|
||||||
end |
|
@ -1,24 +0,0 @@ |
|||||||
class Form::Lettings::Pages::MinRentValueCheck < ::Form::Page |
|
||||||
def initialize(id, hsh, subsection, check_answers_card_number: nil) |
|
||||||
super(id, hsh, subsection) |
|
||||||
@depends_on = [{ "rent_in_soft_min_range?" => true }] |
|
||||||
@title_text = { |
|
||||||
"translation" => "soft_validations.rent.outside_range_title", |
|
||||||
"arguments" => [{ |
|
||||||
"key" => "brent", |
|
||||||
"label" => true, |
|
||||||
"i18n_template" => "brent", |
|
||||||
}], |
|
||||||
} |
|
||||||
@informative_text = I18n.t("soft_validations.rent.informative_text", higher_or_lower: "lower") |
|
||||||
@check_answers_card_number = check_answers_card_number |
|
||||||
end |
|
||||||
|
|
||||||
def questions |
|
||||||
@questions ||= [Form::Lettings::Questions::MinRentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)] |
|
||||||
end |
|
||||||
|
|
||||||
def interruption_screen_question_ids |
|
||||||
%w[brent period startdate uprn postcode_full la beds rent_type needstype] |
|
||||||
end |
|
||||||
end |
|
@ -0,0 +1,35 @@ |
|||||||
|
class Form::Lettings::Pages::RentValueCheck < ::Form::Page |
||||||
|
def initialize(id, hsh, subsection, check_answers_card_number: nil) |
||||||
|
super(id, hsh, subsection) |
||||||
|
@depends_on = [{ "rent_soft_validation_triggered?" => true }] |
||||||
|
@title_text = { |
||||||
|
"translation" => "soft_validations.rent.outside_range_title", |
||||||
|
"arguments" => [ |
||||||
|
{ |
||||||
|
"key" => "brent", |
||||||
|
"label" => true, |
||||||
|
"i18n_template" => "brent", |
||||||
|
}, |
||||||
|
], |
||||||
|
} |
||||||
|
@informative_text = { |
||||||
|
"translation" => "soft_validations.rent.informative_text", |
||||||
|
"arguments" => [ |
||||||
|
{ |
||||||
|
"key" => "rent_soft_validation_higher_or_lower_text", |
||||||
|
"label" => false, |
||||||
|
"i18n_template" => "higher_or_lower", |
||||||
|
}, |
||||||
|
], |
||||||
|
} |
||||||
|
@check_answers_card_number = check_answers_card_number |
||||||
|
end |
||||||
|
|
||||||
|
def questions |
||||||
|
@questions ||= [Form::Lettings::Questions::RentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)] |
||||||
|
end |
||||||
|
|
||||||
|
def interruption_screen_question_ids |
||||||
|
%w[brent period startdate uprn postcode_full la beds rent_type needstype] |
||||||
|
end |
||||||
|
end |
@ -1,15 +0,0 @@ |
|||||||
class Form::Lettings::Questions::MaxRentValueCheck < ::Form::Question |
|
||||||
def initialize(id, hsh, page, check_answers_card_number:) |
|
||||||
super(id, hsh, page) |
|
||||||
@id = "rent_value_check" |
|
||||||
@check_answer_label = "Total rent confirmation" |
|
||||||
@header = "Are you sure this is correct?" |
|
||||||
@type = "interruption_screen" |
|
||||||
@hint_text = I18n.t("soft_validations.rent.hint_text", higher_or_lower: "higher") |
|
||||||
@check_answers_card_number = check_answers_card_number |
|
||||||
@answer_options = ANSWER_OPTIONS |
|
||||||
@hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] } |
|
||||||
end |
|
||||||
|
|
||||||
ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze |
|
||||||
end |
|
@ -1,11 +1,11 @@ |
|||||||
class Form::Lettings::Questions::MinRentValueCheck < ::Form::Question |
class Form::Lettings::Questions::RentValueCheck < ::Form::Question |
||||||
def initialize(id, hsh, page, check_answers_card_number:) |
def initialize(id, hsh, page, check_answers_card_number:) |
||||||
super(id, hsh, page) |
super(id, hsh, page) |
||||||
@id = "rent_value_check" |
@id = "rent_value_check" |
||||||
@check_answer_label = "Total rent confirmation" |
@check_answer_label = "Total rent confirmation" |
||||||
@header = "Are you sure this is correct?" |
@header = "Are you sure this is correct?" |
||||||
@type = "interruption_screen" |
@type = "interruption_screen" |
||||||
@hint_text = I18n.t("soft_validations.rent.hint_text", higher_or_lower: "lower") |
@hint_text = I18n.t("soft_validations.rent.hint_text") |
||||||
@check_answers_card_number = check_answers_card_number |
@check_answers_card_number = check_answers_card_number |
||||||
@answer_options = ANSWER_OPTIONS |
@answer_options = ANSWER_OPTIONS |
||||||
@hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] } |
@hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] } |
@ -1,33 +0,0 @@ |
|||||||
require "rails_helper" |
|
||||||
|
|
||||||
RSpec.describe Form::Lettings::Pages::MaxRentValueCheck, type: :model do |
|
||||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
|
||||||
|
|
||||||
let(:page_id) { "max_rent_value_check" } |
|
||||||
let(:page_definition) { nil } |
|
||||||
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1))) } |
|
||||||
|
|
||||||
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[rent_value_check]) |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct id" do |
|
||||||
expect(page.id).to eq("max_rent_value_check") |
|
||||||
end |
|
||||||
|
|
||||||
it "has correct depends_on" do |
|
||||||
expect(page.depends_on).to eq([{ "rent_in_soft_max_range?" => true }]) |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct title_text" do |
|
||||||
expect(page.title_text).to eq({ "arguments" => [{ "i18n_template" => "brent", "key" => "brent", "label" => true }], "translation" => "soft_validations.rent.outside_range_title" }) |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct interruption_screen_question_ids" do |
|
||||||
expect(page.interruption_screen_question_ids).to eq(%w[brent period startdate uprn postcode_full la beds rent_type needstype]) |
|
||||||
end |
|
||||||
end |
|
@ -1,42 +0,0 @@ |
|||||||
require "rails_helper" |
|
||||||
|
|
||||||
RSpec.describe Form::Lettings::Pages::MinRentValueCheck, type: :model do |
|
||||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
|
||||||
|
|
||||||
let(:page_id) { "min_rent_value_check" } |
|
||||||
let(:page_definition) { nil } |
|
||||||
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1))) } |
|
||||||
|
|
||||||
it "has correct subsection" do |
|
||||||
expect(page.subsection).to eq(subsection) |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct description" do |
|
||||||
expect(page.description).to be nil |
|
||||||
end |
|
||||||
|
|
||||||
it "has correct questions" do |
|
||||||
expect(page.questions.map(&:id)).to eq(%w[rent_value_check]) |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct id" do |
|
||||||
expect(page.id).to eq("min_rent_value_check") |
|
||||||
end |
|
||||||
|
|
||||||
it "has correct depends_on" do |
|
||||||
expect(page.depends_on).to eq( |
|
||||||
[{ "rent_in_soft_min_range?" => true }], |
|
||||||
) |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct title_text" do |
|
||||||
expect(page.title_text).to eq({ |
|
||||||
"translation" => "soft_validations.rent.outside_range_title", |
|
||||||
"arguments" => [{ "i18n_template" => "brent", "key" => "brent", "label" => true }], |
|
||||||
}) |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct interruption_screen_question_ids" do |
|
||||||
expect(page.interruption_screen_question_ids).to eq(%w[brent period startdate uprn postcode_full la beds rent_type needstype]) |
|
||||||
end |
|
||||||
end |
|
@ -1,32 +0,0 @@ |
|||||||
require "rails_helper" |
|
||||||
|
|
||||||
RSpec.describe Form::Lettings::Questions::MaxRentValueCheck, type: :model do |
|
||||||
subject(:question) { described_class.new(nil, question_definition, page, check_answers_card_number:) } |
|
||||||
|
|
||||||
let(:question_definition) { nil } |
|
||||||
let(:check_answers_card_number) { 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("rent_value_check") |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct type" do |
|
||||||
expect(question.type).to eq("interruption_screen") |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct answer_options" do |
|
||||||
expect(question.answer_options).to eq({ |
|
||||||
"0" => { "value" => "Yes" }, |
|
||||||
"1" => { "value" => "No" }, |
|
||||||
}) |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct hidden_in_check_answers" do |
|
||||||
expect(question.hidden_in_check_answers).to eq({ "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] }) |
|
||||||
end |
|
||||||
end |
|
@ -1,32 +0,0 @@ |
|||||||
require "rails_helper" |
|
||||||
|
|
||||||
RSpec.describe Form::Lettings::Questions::MinRentValueCheck, type: :model do |
|
||||||
subject(:question) { described_class.new(nil, question_definition, page, check_answers_card_number:) } |
|
||||||
|
|
||||||
let(:question_definition) { nil } |
|
||||||
let(:check_answers_card_number) { 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("rent_value_check") |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct type" do |
|
||||||
expect(question.type).to eq("interruption_screen") |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct answer_options" do |
|
||||||
expect(question.answer_options).to eq({ |
|
||||||
"0" => { "value" => "Yes" }, |
|
||||||
"1" => { "value" => "No" }, |
|
||||||
}) |
|
||||||
end |
|
||||||
|
|
||||||
it "has the correct hidden_in_check_answers" do |
|
||||||
expect(question.hidden_in_check_answers).to eq({ "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] }) |
|
||||||
end |
|
||||||
end |
|
Loading…
Reference in new issue