Browse Source

Use build_stubbed where necessary for lettings logs in tests

pull/2444/head
Rachael Booth 2 years ago
parent
commit
00bfba3293
  1. 2
      spec/helpers/tasklist_helper_spec.rb
  2. 2
      spec/models/form_spec.rb
  3. 8
      spec/models/lettings_log_spec.rb
  4. 12
      spec/models/log_spec.rb

2
spec/helpers/tasklist_helper_spec.rb

@ -13,7 +13,7 @@ RSpec.describe TasklistHelper do
describe "with lettings" do describe "with lettings" do
let(:empty_lettings_log) { create(:lettings_log) } let(:empty_lettings_log) { create(:lettings_log) }
let(:lettings_log) { build(:lettings_log, :in_progress, needstype: 1, startdate: now) } let(:lettings_log) { build_stubbed(:lettings_log, :in_progress, needstype: 1, startdate: now) }
describe "get next incomplete section" do describe "get next incomplete section" do
it "returns the first subsection name if it is not completed" do it "returns the first subsection name if it is not completed" do

2
spec/models/form_spec.rb

@ -84,7 +84,7 @@ RSpec.describe Form, type: :model do
end end
describe "next_incomplete_section_redirect_path" do describe "next_incomplete_section_redirect_path" do
let(:lettings_log) { FactoryBot.build(:lettings_log, :in_progress) } let(:lettings_log) { FactoryBot.build_stubbed(:lettings_log, :in_progress) }
let(:subsection) { form.get_subsection("household_characteristics") } let(:subsection) { form.get_subsection("household_characteristics") }
let(:later_subsection) { form.get_subsection("declaration") } let(:later_subsection) { form.get_subsection("declaration") }

8
spec/models/lettings_log_spec.rb

@ -3551,7 +3551,7 @@ RSpec.describe LettingsLog do
end end
context "when setup section has been completed" do context "when setup section has been completed" do
let(:lettings_log) { build(:lettings_log, :setup_completed) } let(:lettings_log) { build_stubbed(:lettings_log, :setup_completed) }
it "returns true" do it "returns true" do
expect(lettings_log).to be_non_location_setup_questions_completed expect(lettings_log).to be_non_location_setup_questions_completed
@ -3559,7 +3559,7 @@ RSpec.describe LettingsLog do
end end
context "when the declaration has not been completed for a 2024 log" do context "when the declaration has not been completed for a 2024 log" do
let(:lettings_log) { build(:lettings_log, :setup_completed, startdate: Time.utc(2024, 10, 1), declaration: nil) } let(:lettings_log) { build_stubbed(:lettings_log, :setup_completed, startdate: Time.utc(2024, 10, 1), declaration: nil) }
it "returns false" do it "returns false" do
expect(lettings_log).not_to be_non_location_setup_questions_completed expect(lettings_log).not_to be_non_location_setup_questions_completed
@ -3567,7 +3567,7 @@ RSpec.describe LettingsLog do
end end
context "when an optional question has not been completed" do context "when an optional question has not been completed" do
let(:lettings_log) { build(:lettings_log, :setup_completed, propcode: nil) } let(:lettings_log) { build_stubbed(:lettings_log, :setup_completed, propcode: nil) }
it "returns true" do it "returns true" do
expect(lettings_log).to be_non_location_setup_questions_completed expect(lettings_log).to be_non_location_setup_questions_completed
@ -3575,7 +3575,7 @@ RSpec.describe LettingsLog do
end end
context "when scheme and location have not been completed" do context "when scheme and location have not been completed" do
let(:lettings_log) { build(:lettings_log, :setup_completed, :sh, scheme_id: nil, location_id: nil) } let(:lettings_log) { build_stubbed(:lettings_log, :setup_completed, :sh, scheme_id: nil, location_id: nil) }
it "returns true" do it "returns true" do
expect(lettings_log).to be_non_location_setup_questions_completed expect(lettings_log).to be_non_location_setup_questions_completed

12
spec/models/log_spec.rb

@ -30,7 +30,7 @@ RSpec.describe Log, type: :model do
describe "#blank_invalid_non_setup_fields!" do describe "#blank_invalid_non_setup_fields!" do
context "when a setup field is invalid for a lettings log" do context "when a setup field is invalid for a lettings log" do
subject(:model) { build(:lettings_log, needstype: 404) } subject(:model) { build_stubbed(:lettings_log, needstype: 404) }
it "does not blank it" do it "does not blank it" do
model.valid? model.valid?
@ -39,7 +39,7 @@ RSpec.describe Log, type: :model do
end end
context "when a setup field is invalid for a sales log" do context "when a setup field is invalid for a sales log" do
subject(:model) { build(:sales_log, companybuy: 404) } subject(:model) { build_stubbed(:sales_log, companybuy: 404) }
it "does not blank it" do it "does not blank it" do
model.valid? model.valid?
@ -48,7 +48,7 @@ RSpec.describe Log, type: :model do
end end
context "when a non setup field is invalid for a lettings log" do context "when a non setup field is invalid for a lettings log" do
subject(:model) { build(:lettings_log, :completed, startdate: Time.zone.local(2023, 12, 12), offered: 234) } subject(:model) { build_stubbed(:lettings_log, :completed, startdate: Time.zone.local(2023, 12, 12), offered: 234) }
it "blanks it" do it "blanks it" do
model.valid? model.valid?
@ -58,7 +58,7 @@ RSpec.describe Log, type: :model do
end end
context "when a non setup field is invalid for a sales log" do context "when a non setup field is invalid for a sales log" do
subject(:model) { build(:sales_log, :completed, age1: 10) } subject(:model) { build_stubbed(:sales_log, :completed, age1: 10) }
it "blanks it" do it "blanks it" do
model.valid? model.valid?
@ -68,7 +68,7 @@ RSpec.describe Log, type: :model do
end end
context "when prevloc is invalid for a lettings log" do context "when prevloc is invalid for a lettings log" do
subject(:model) { build(:lettings_log, :completed, previous_la_known: 1, prevloc: nil) } subject(:model) { build_stubbed(:lettings_log, :completed, previous_la_known: 1, prevloc: nil) }
it "blanks previous_la_known" do it "blanks previous_la_known" do
model.valid? model.valid?
@ -78,7 +78,7 @@ RSpec.describe Log, type: :model do
end end
context "when hhmemb is invalid for a lettings log" do context "when hhmemb is invalid for a lettings log" do
subject(:model) { build(:lettings_log, :setup_completed, hhmemb: 1, joint: 1) } subject(:model) { build_stubbed(:lettings_log, :setup_completed, hhmemb: 1, joint: 1) }
it "does not blank it" do it "does not blank it" do
model.valid? model.valid?

Loading…
Cancel
Save