Browse Source

Fix some tests

further-bulk-upload-year-fixes
Kat 2 years ago
parent
commit
f6ec38e5d7
  1. 9
      spec/components/check_answers_summary_list_card_component_spec.rb
  2. 2
      spec/models/form/lettings/pages/address_spec.rb
  3. 9
      spec/models/sales_log_spec.rb
  4. 9
      spec/models/validations/sales/setup_validations_spec.rb
  5. 11
      spec/models/validations/soft_validations_spec.rb

9
spec/components/check_answers_summary_list_card_component_spec.rb

@ -6,6 +6,15 @@ RSpec.describe CheckAnswersSummaryListCardComponent, type: :component do
let(:rendered) { render_inline(component) }
context "when before 23/24 collection" do
before do
Timecop.freeze(Time.zone.local(2023, 1, 10))
Singleton.__init__(FormHandler)
end
after do
Timecop.return
end
context "when given a set of questions" do
let(:user) { build(:user) }
let(:log) { build(:lettings_log, :completed, age2: 99, startdate: Time.zone.local(2021, 5, 1)) }

2
spec/models/form/lettings/pages/address_spec.rb

@ -62,7 +62,7 @@ RSpec.describe Form::Lettings::Pages::Address, type: :model do
context "when uprn_confirmed == 1 && uprn_known != 0" do
let(:log) do
create(:lettings_log, uprn_known: 1, uprn_confirmed: 1)
create(:lettings_log, uprn_known: 1, uprn_confirmed: 1, uprn: "123456789")
end
it "returns true" do

9
spec/models/sales_log_spec.rb

@ -91,6 +91,15 @@ RSpec.describe SalesLog, type: :model do
let(:sales_log) { build(:sales_log, created_by: created_by_user) }
let(:sales_log_2) { build(:sales_log, saledate: Time.zone.local(2022, 5, 1), created_by: created_by_user) }
before do
Timecop.freeze(Time.zone.local(2023, 1, 10))
Singleton.__init__(FormHandler)
end
after do
Timecop.return
end
it "has returns the correct form based on the start date" do
expect(sales_log.form_name).to be_nil
expect(sales_log.form).to be_a(Form)

9
spec/models/validations/sales/setup_validations_spec.rb

@ -7,6 +7,15 @@ RSpec.describe Validations::Sales::SetupValidations do
describe "#validate_saledate_collection_year" do
context "with sales_in_crossover_period == false" do
before do
Timecop.freeze(Time.zone.local(2023, 1, 10))
Singleton.__init__(FormHandler)
end
after do
Timecop.return
end
context "when saledate is blank" do
let(:record) { build(:sales_log, saledate: nil) }

11
spec/models/validations/soft_validations_spec.rb

@ -4,6 +4,15 @@ RSpec.describe Validations::SoftValidations do
let(:organisation) { FactoryBot.create(:organisation, provider_type: "PRP") }
let(:record) { FactoryBot.create(:lettings_log, owning_organisation: organisation) }
before do
Timecop.freeze(Time.zone.local(2021, 10, 10))
Singleton.__init__(FormHandler)
end
after do
Timecop.return
end
describe "rent min max validations" do
before do
LaRentRange.create!(
@ -23,7 +32,7 @@ RSpec.describe Validations::SoftValidations do
record.rent_type = 0
record.beds = 1
record.period = 1
record.startdate = Time.zone.local(2021, 10, 10)
record.startdate = Time.zone.today
end
context "when validating soft min" do

Loading…
Cancel
Save