Browse Source
* Update discounted ownership guidance * Add top guidance partial to outright sale * Update outright sale guidance content * Update model testpull/2546/head
7 changed files with 167 additions and 20 deletions
@ -1,8 +1,13 @@
|
||||
<%= govuk_details(summary_text: "How the financial values are calculated") do %> |
||||
<p class="govuk-body"> |
||||
The mortgage amount <%= question_link("mortgage", log, current_user) %> |
||||
and cash deposit <%= question_link("deposit", log, current_user) %> |
||||
added together must equal |
||||
the purchase price <%= question_link("value", log, current_user) %> |
||||
</p> |
||||
<% if log.mortgage_used? || log.mortgageused.blank? %> |
||||
<% mortgage_question_link = log.mortgageused.blank? ? question_link("mortgageused", log, current_user) : question_link("mortgage", log, current_user) %> |
||||
The mortgage amount <%= mortgage_question_link %> |
||||
and cash deposit <%= question_link("deposit", log, current_user) %> |
||||
added together must equal |
||||
<% else %> |
||||
Cash deposit <%= question_link("deposit", log, current_user) %> must equal |
||||
<% end %> |
||||
the purchase price <%= question_link("value", log, current_user) %> |
||||
</p> |
||||
<% end %> |
||||
|
||||
@ -0,0 +1,85 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe "form/guidance/_financial_calculations_discounted_ownership.html.erb" do |
||||
let(:log) { create(:sales_log) } |
||||
|
||||
let(:fragment) { Capybara::Node::Simple.new(rendered) } |
||||
|
||||
context "when mortgage used is not answered" do |
||||
let(:log) { create(:sales_log, :completed, ownershipsch: 2, type: 9, mortgageused: nil, discount: 30) } |
||||
|
||||
it "renders correct content" do |
||||
render partial: "form/guidance/financial_calculations_discounted_ownership", locals: { log:, current_user: log.assigned_to } |
||||
expect(fragment).to have_content("The mortgage amount") |
||||
expect(fragment).to have_content("and cash deposit") |
||||
expect(fragment).to have_content("added together must equal") |
||||
expect(fragment).to have_content("the purchase price") |
||||
expect(fragment).to have_content("subtracted by the sum of the purchase price") |
||||
expect(fragment).to have_content("multiplied by the discount") |
||||
end |
||||
end |
||||
|
||||
context "when mortgage used is no" do |
||||
let(:log) { create(:sales_log, :completed, ownershipsch: 2, type: 9, mortgageused: 2, discount: nil) } |
||||
|
||||
it "renders correct content" do |
||||
render partial: "form/guidance/financial_calculations_discounted_ownership", locals: { log:, current_user: log.assigned_to } |
||||
expect(fragment).to have_content("Cash deposit") |
||||
expect(fragment).to have_content("must equal") |
||||
expect(fragment).to have_content("the purchase price") |
||||
expect(fragment).to have_content("subtracted by the sum of the purchase price") |
||||
expect(fragment).to have_content("multiplied by the discount") |
||||
|
||||
expect(fragment).not_to have_content("The mortgage amount") |
||||
expect(fragment).not_to have_content("added together must equal") |
||||
end |
||||
end |
||||
|
||||
context "when mortgage used is yes" do |
||||
let(:log) { create(:sales_log, :completed, ownershipsch: 2, type: 9, mortgageused: 1, mortgage: nil, discount: 30) } |
||||
|
||||
it "renders correct content" do |
||||
render partial: "form/guidance/financial_calculations_discounted_ownership", locals: { log:, current_user: log.assigned_to } |
||||
expect(fragment).to have_content("The mortgage amount") |
||||
expect(fragment).to have_content("and cash deposit") |
||||
expect(fragment).to have_content("added together must equal") |
||||
expect(fragment).to have_content("the purchase price") |
||||
expect(fragment).to have_content("subtracted by the sum of the purchase price") |
||||
expect(fragment).to have_content("multiplied by the discount") |
||||
end |
||||
end |
||||
|
||||
context "when grant is routed to" do |
||||
context "and morgage used" do |
||||
let(:log) { create(:sales_log, :completed, ownershipsch: 2, type: 22, mortgageused: 1, mortgage: nil, discount: 30) } |
||||
|
||||
it "renders correct content" do |
||||
render partial: "form/guidance/financial_calculations_discounted_ownership", locals: { log:, current_user: log.assigned_to } |
||||
expect(fragment).to have_content("The mortgage amount") |
||||
expect(fragment).to have_content("cash deposit") |
||||
expect(fragment).to have_content("and grant") |
||||
expect(fragment).to have_content("added together must equal") |
||||
expect(fragment).to have_content("the purchase price") |
||||
|
||||
expect(fragment).not_to have_content("subtracted by the sum of the purchase price") |
||||
expect(fragment).not_to have_content("multiplied by the discount") |
||||
end |
||||
end |
||||
|
||||
context "and morgage not used" do |
||||
let(:log) { create(:sales_log, :completed, ownershipsch: 2, type: 22, mortgageused: 2, grant: nil) } |
||||
|
||||
it "renders correct content" do |
||||
render partial: "form/guidance/financial_calculations_discounted_ownership", locals: { log:, current_user: log.assigned_to } |
||||
expect(fragment).to have_content("Cash deposit") |
||||
expect(fragment).to have_content("and grant") |
||||
expect(fragment).to have_content("added together must equal") |
||||
expect(fragment).to have_content("the purchase price") |
||||
|
||||
expect(fragment).not_to have_content("The mortgage amount") |
||||
expect(fragment).not_to have_content("subtracted by the sum of the purchase price") |
||||
expect(fragment).not_to have_content("multiplied by the discount") |
||||
end |
||||
end |
||||
end |
||||
end |
||||
@ -0,0 +1,45 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe "form/guidance/_financial_calculations_outright_sale.html.erb" do |
||||
let(:log) { create(:sales_log) } |
||||
|
||||
let(:fragment) { Capybara::Node::Simple.new(rendered) } |
||||
|
||||
context "when mortgage used is not answered" do |
||||
let(:log) { create(:sales_log, :outright_sale_setup_complete, ownershipsch: 3, type: 10, mortgageused: nil, discount: 30) } |
||||
|
||||
it "renders correct content" do |
||||
render partial: "form/guidance/financial_calculations_outright_sale", locals: { log:, current_user: log.assigned_to } |
||||
expect(fragment).to have_content("The mortgage amount") |
||||
expect(fragment).to have_content("and cash deposit") |
||||
expect(fragment).to have_content("added together must equal") |
||||
expect(fragment).to have_content("the purchase price") |
||||
end |
||||
end |
||||
|
||||
context "when mortgage used is no" do |
||||
let(:log) { create(:sales_log, :outright_sale_setup_complete, ownershipsch: 3, type: 10, mortgageused: 2, discount: nil) } |
||||
|
||||
it "renders correct content" do |
||||
render partial: "form/guidance/financial_calculations_outright_sale", locals: { log:, current_user: log.assigned_to } |
||||
expect(fragment).to have_content("Cash deposit") |
||||
expect(fragment).to have_content("must equal") |
||||
expect(fragment).to have_content("the purchase price") |
||||
|
||||
expect(fragment).not_to have_content("The mortgage amount") |
||||
expect(fragment).not_to have_content("added together must equal") |
||||
end |
||||
end |
||||
|
||||
context "when mortgage used is yes" do |
||||
let(:log) { create(:sales_log, :outright_sale_setup_complete, ownershipsch: 3, type: 10, mortgageused: 1, mortgage: nil, discount: 30) } |
||||
|
||||
it "renders correct content" do |
||||
render partial: "form/guidance/financial_calculations_outright_sale", locals: { log:, current_user: log.assigned_to } |
||||
expect(fragment).to have_content("The mortgage amount") |
||||
expect(fragment).to have_content("and cash deposit") |
||||
expect(fragment).to have_content("added together must equal") |
||||
expect(fragment).to have_content("the purchase price") |
||||
end |
||||
end |
||||
end |
||||
Loading…
Reference in new issue