Browse Source

CLDC-4074: Update more failing tests

CLDC-4074-update-tests
Samuel Young 2 weeks ago
parent
commit
2e59ae955d
  1. 5
      spec/models/sales_log_spec.rb
  2. 30
      spec/requests/lettings_logs_controller_spec.rb
  3. 10
      spec/views/form/guidance/_financial_calculations_outright_sale_spec.rb

5
spec/models/sales_log_spec.rb

@ -7,6 +7,7 @@ RSpec.describe SalesLog, type: :model do
let(:owning_organisation) { create(:organisation) } let(:owning_organisation) { create(:organisation) }
let(:assigned_to_user) { create(:user) } let(:assigned_to_user) { create(:user) }
let(:current_date) { current_collection_start_date }
include_examples "shared log examples", :sales_log include_examples "shared log examples", :sales_log
@ -1088,8 +1089,8 @@ RSpec.describe SalesLog, type: :model do
context "when form year changes and LA is no longer active" do context "when form year changes and LA is no longer active" do
let!(:sales_log) { create(:sales_log) } let!(:sales_log) { create(:sales_log) }
let(:end_date) { Time.zone.local(2025, 3, 30) } let(:end_date) { current_date }
let(:date_after_end_date) { Time.zone.local(2025, 3, 31) } let(:date_after_end_date) { current_date + 1.day }
before do before do
LocalAuthority.find_by(code: "E08000003").update!(end_date:) LocalAuthority.find_by(code: "E08000003").update!(end_date:)

30
spec/requests/lettings_logs_controller_spec.rb

@ -1218,32 +1218,6 @@ RSpec.describe LettingsLogsController, type: :request do
end end
end end
context "when a lettings log is for a renewal of supported housing in 2024" do
let(:lettings_log) { create(:lettings_log, :startdate_today, assigned_to: user, renewal: 1, needstype: 2, rent_type: 3, postcode_known: 0, startdate: Time.zone.local(2024, 10, 20)) }
before do
Timecop.freeze(2024, 10, 15)
Singleton.__init__(FormHandler)
lettings_log.startdate = Time.zone.local(2024, 10, 20)
lettings_log.save!
end
after do
Timecop.return
Singleton.__init__(FormHandler)
end
it "does not show property information" do
get lettings_log_path(lettings_log)
expect(page).to have_content "Tenancy information"
expect(page).not_to have_content "Property information"
end
it "does not crash the app if postcode_known is not nil" do
expect { get lettings_log_path(lettings_log) }.not_to raise_error
end
end
context "when a lettings log is for a renewal of supported housing in 2025" do context "when a lettings log is for a renewal of supported housing in 2025" do
let(:lettings_log) { create(:lettings_log, :startdate_today, assigned_to: user, renewal: 1, needstype: 2, rent_type: 3, postcode_known: 0) } let(:lettings_log) { create(:lettings_log, :startdate_today, assigned_to: user, renewal: 1, needstype: 2, rent_type: 3, postcode_known: 0) }
@ -1588,7 +1562,7 @@ RSpec.describe LettingsLogsController, type: :request do
end end
context "when viewing a specific log affected by deactivated location" do context "when viewing a specific log affected by deactivated location" do
let!(:affected_lettings_log) { FactoryBot.create(:lettings_log, unresolved: true, assigned_to: user, needstype: 2, startdate: Time.zone.local(2024, 4, 1)) } let!(:affected_lettings_log) { FactoryBot.create(:lettings_log, unresolved: true, assigned_to: user, needstype: 2) }
let(:headers) { { "Accept" => "text/html" } } let(:headers) { { "Accept" => "text/html" } }
before do before do
@ -1600,8 +1574,6 @@ RSpec.describe LettingsLogsController, type: :request do
it "routes to the tenancy date question" do it "routes to the tenancy date question" do
get "/lettings-logs/#{affected_lettings_log.id}", headers:, params: {} get "/lettings-logs/#{affected_lettings_log.id}", headers:, params: {}
expect(response).to redirect_to("/lettings-logs/#{affected_lettings_log.id}/tenancy-start-date") expect(response).to redirect_to("/lettings-logs/#{affected_lettings_log.id}/tenancy-start-date")
follow_redirect!
expect(page).to have_content("What is the tenancy start date?")
end end
it "tenancy start date page links to the scheme page" do it "tenancy start date page links to the scheme page" do

10
spec/views/form/guidance/_financial_calculations_outright_sale_spec.rb

@ -1,12 +1,14 @@
require "rails_helper" require "rails_helper"
RSpec.describe "form/guidance/_financial_calculations_outright_sale.html.erb" do RSpec.describe "form/guidance/_financial_calculations_outright_sale.html.erb" do
let(:log) { create(:sales_log) } include CollectionTimeHelper
let(:log) { create(:sales_log) }
let(:current_date) { current_collection_start_date }
let(:fragment) { Capybara::Node::Simple.new(rendered) } let(:fragment) { Capybara::Node::Simple.new(rendered) }
context "when mortgage used is not answered" do 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, saledate: Time.zone.local(2024, 11, 1)) } let(:log) { create(:sales_log, :shared_ownership_setup_complete, mortgageused: nil, saledate: current_date) }
it "renders correct content" do it "renders correct content" do
render partial: "form/guidance/financial_calculations_outright_sale", locals: { log:, current_user: log.assigned_to } render partial: "form/guidance/financial_calculations_outright_sale", locals: { log:, current_user: log.assigned_to }
@ -18,7 +20,7 @@ RSpec.describe "form/guidance/_financial_calculations_outright_sale.html.erb" do
end end
context "when mortgage used is no" do context "when mortgage used is no" do
let(:log) { create(:sales_log, :outright_sale_setup_complete, ownershipsch: 3, type: 10, mortgageused: 2, discount: nil, saledate: Time.zone.local(2024, 11, 1)) } let(:log) { create(:sales_log, :shared_ownership_setup_complete, mortgageused: 2, saledate: current_date) }
it "renders correct content" do it "renders correct content" do
render partial: "form/guidance/financial_calculations_outright_sale", locals: { log:, current_user: log.assigned_to } render partial: "form/guidance/financial_calculations_outright_sale", locals: { log:, current_user: log.assigned_to }
@ -32,7 +34,7 @@ RSpec.describe "form/guidance/_financial_calculations_outright_sale.html.erb" do
end end
context "when mortgage used is yes" do 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, saledate: Time.zone.local(2024, 11, 1)) } let(:log) { create(:sales_log, :shared_ownership_setup_complete, mortgageused: 1, saledate: current_date) }
it "renders correct content" do it "renders correct content" do
render partial: "form/guidance/financial_calculations_outright_sale", locals: { log:, current_user: log.assigned_to } render partial: "form/guidance/financial_calculations_outright_sale", locals: { log:, current_user: log.assigned_to }

Loading…
Cancel
Save