From 63ec77c93bc0d569548f30d8df8ffd3a45f7958f Mon Sep 17 00:00:00 2001 From: Jack S Date: Wed, 15 Mar 2023 10:29:30 +0000 Subject: [PATCH] Update optional fields --- app/models/form.rb | 2 +- app/models/lettings_log.rb | 2 + app/models/sales_log.rb | 2 + spec/models/lettings_log_spec.rb | 165 ++++++++++++++++++------------- spec/models/sales_log_spec.rb | 38 +++++-- 5 files changed, 133 insertions(+), 76 deletions(-) diff --git a/app/models/form.rb b/app/models/form.rb index f9959959e..c7bb4f2b0 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -160,7 +160,7 @@ class Form def invalidated_page_questions(log, current_user = nil) # we're already treating these fields as a special case and reset their values upon saving a log - callback_questions = %w[postcode_known la ppcodenk previous_la_known prevloc postcode_full ppostcode_full location_id] + callback_questions = %w[postcode_known la ppcodenk previous_la_known prevloc postcode_full ppostcode_full location_id address_line1 address_line2 town_or_city county] questions.reject { |q| q.page.routed_to?(log, current_user) || q.derived? || callback_questions.include?(q.id) } || [] end diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index dad1ef705..57766a405 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -562,6 +562,8 @@ private not_required << "tshortfall" if tshortfall_unknown? not_required << "tenancylength" if tenancylength_optional? + not_required |= %w[address_line2 county postcode_full] if startdate && startdate.year >= 2023 + not_required end diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index e15b9c610..de1e1e2ba 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -78,6 +78,8 @@ class SalesLog < Log not_required = [] not_required << "proplen" if proplen_optional? + not_required |= %w[address_line2 county postcode_full] if saledate && saledate.year >= 2023 + not_required end diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb index c6f559aec..d233ecba9 100644 --- a/spec/models/lettings_log_spec.rb +++ b/spec/models/lettings_log_spec.rb @@ -2,8 +2,8 @@ require "rails_helper" require "shared/shared_examples_for_derived_fields" RSpec.describe LettingsLog do - let(:different_managing_organisation) { FactoryBot.create(:organisation) } - let(:created_by_user) { FactoryBot.create(:user) } + let(:different_managing_organisation) { create(:organisation) } + let(:created_by_user) { create(:user) } let(:owning_organisation) { created_by_user.organisation } let(:fake_2021_2022_form) { Form.new("spec/fixtures/forms/2021_2022.json") } @@ -19,19 +19,19 @@ RSpec.describe LettingsLog do end it "is a not a sales log" do - lettings_log = FactoryBot.build(:lettings_log, created_by: created_by_user) + lettings_log = build(:lettings_log, created_by: created_by_user) expect(lettings_log.sales?).to be false end it "is a lettings log" do - lettings_log = FactoryBot.build(:lettings_log, created_by: created_by_user) + lettings_log = build(:lettings_log, created_by: created_by_user) expect(lettings_log).to be_lettings end describe "#form" do - let(:lettings_log) { FactoryBot.build(:lettings_log, created_by: created_by_user) } - let(:lettings_log_2) { FactoryBot.build(:lettings_log, startdate: Time.zone.local(2022, 1, 1), created_by: created_by_user) } - let(:lettings_log_year_2) { FactoryBot.build(:lettings_log, startdate: Time.zone.local(2023, 5, 1), created_by: created_by_user) } + let(:lettings_log) { build(:lettings_log, created_by: created_by_user) } + let(:lettings_log_2) { build(:lettings_log, startdate: Time.zone.local(2022, 1, 1), created_by: created_by_user) } + let(:lettings_log_year_2) { build(:lettings_log, startdate: Time.zone.local(2023, 5, 1), created_by: created_by_user) } it "has returns the correct form based on the start date" do expect(lettings_log.form_name).to be_nil @@ -43,7 +43,7 @@ RSpec.describe LettingsLog do end context "when a date outside the collection window is passed" do - let(:lettings_log) { FactoryBot.build(:lettings_log, startdate: Time.zone.local(2015, 1, 1), created_by: created_by_user) } + let(:lettings_log) { build(:lettings_log, startdate: Time.zone.local(2015, 1, 1), created_by: created_by_user) } it "returns the first form" do expect(lettings_log.form).to be_a(Form) @@ -70,7 +70,7 @@ RSpec.describe LettingsLog do end describe "#update" do - let(:lettings_log) { FactoryBot.create(:lettings_log, created_by: created_by_user) } + let(:lettings_log) { create(:lettings_log, created_by: created_by_user) } let(:validator) { lettings_log._validators[nil].first } after do @@ -168,9 +168,9 @@ RSpec.describe LettingsLog do end describe "status" do - let!(:empty_lettings_log) { FactoryBot.create(:lettings_log) } - let!(:in_progress_lettings_log) { FactoryBot.create(:lettings_log, :in_progress) } - let!(:completed_lettings_log) { FactoryBot.create(:lettings_log, :completed) } + let!(:empty_lettings_log) { create(:lettings_log) } + let!(:in_progress_lettings_log) { create(:lettings_log, :in_progress) } + let!(:completed_lettings_log) { create(:lettings_log, :completed) } it "is set to not started for an empty lettings log" do expect(empty_lettings_log.not_started?).to be(true) @@ -208,7 +208,7 @@ RSpec.describe LettingsLog do describe "weekly_net_income" do let(:net_income) { 5000 } - let(:lettings_log) { FactoryBot.build(:lettings_log, earnings: net_income) } + let(:lettings_log) { build(:lettings_log, earnings: net_income) } it "returns input income if frequency is already weekly" do lettings_log.incfreq = 1 @@ -1860,8 +1860,8 @@ RSpec.describe LettingsLog do end context "and a scheme with a single log is selected" do - let(:scheme) { FactoryBot.create(:scheme) } - let!(:location) { FactoryBot.create(:location, scheme:) } + let(:scheme) { create(:scheme) } + let!(:location) { create(:location, scheme:) } before { lettings_log.update!(startdate: Time.zone.local(2022, 4, 2), scheme:) } @@ -1873,8 +1873,8 @@ RSpec.describe LettingsLog do end context "and not renewal" do - let(:scheme) { FactoryBot.create(:scheme) } - let(:location) { FactoryBot.create(:location, scheme:, postcode: "M11AE", type_of_unit: 1, mobility_type: "W") } + let(:scheme) { create(:scheme) } + let(:location) { create(:location, scheme:, postcode: "M11AE", type_of_unit: 1, mobility_type: "W") } let(:supported_housing_lettings_log) do described_class.create!({ @@ -1916,8 +1916,8 @@ RSpec.describe LettingsLog do end context "and renewal" do - let(:scheme) { FactoryBot.create(:scheme) } - let(:location) { FactoryBot.create(:location, scheme:) } + let(:scheme) { create(:scheme) } + let(:location) { create(:location, scheme:) } let!(:supported_housing_lettings_log) do described_class.create!({ @@ -2035,7 +2035,7 @@ RSpec.describe LettingsLog do end describe "optional fields" do - let(:lettings_log) { FactoryBot.create(:lettings_log) } + let(:lettings_log) { create(:lettings_log) } context "when tshortfall is marked as not known" do it "makes tshortfall optional" do @@ -2043,13 +2043,42 @@ RSpec.describe LettingsLog do expect(lettings_log.optional_fields).to include("tshortfall") end end + + context "when saledate is before 2023" do + let(:lettings_log) { build(:lettings_log, startdate: Time.zone.parse("2022-07-01")) } + + it "returns optional fields" do + expect(lettings_log.optional_fields).to eq(%w[ + first_time_property_let_as_social_housing + tenancycode + propcode + tenancylength + ]) + end + end + + context "when saledate is after 2023" do + let(:lettings_log) { build(:lettings_log, startdate: Time.zone.parse("2023-07-01")) } + + it "returns optional fields" do + expect(lettings_log.optional_fields).to eq(%w[ + first_time_property_let_as_social_housing + tenancycode + propcode + tenancylength + address_line2 + county + postcode_full + ]) + end + end end describe "resetting invalidated fields" do - let(:scheme) { FactoryBot.create(:scheme, owning_organisation: created_by_user.organisation) } - let(:location) { FactoryBot.create(:location, location_code: "E07000223", scheme:) } + let(:scheme) { create(:scheme, owning_organisation: created_by_user.organisation) } + let(:location) { create(:location, location_code: "E07000223", scheme:) } let(:lettings_log) do - FactoryBot.create( + create( :lettings_log, renewal: 0, rsnvac: 5, @@ -2084,14 +2113,14 @@ RSpec.describe LettingsLog do end context "when a question that has already been answered, no longer has met dependencies" do - let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, cbl: 1, preg_occ: 2, wchair: 2) } + let(:lettings_log) { create(:lettings_log, :in_progress, cbl: 1, preg_occ: 2, wchair: 2) } it "clears the answer" do expect { lettings_log.update!(preg_occ: nil) }.to change(lettings_log, :cbl).from(1).to(nil) end context "when the question type does not have answer options" do - let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, housingneeds_a: 1, age1: 19) } + let(:lettings_log) { create(:lettings_log, :in_progress, housingneeds_a: 1, age1: 19) } it "clears the answer" do expect { lettings_log.update!(housingneeds_a: 0) }.to change(lettings_log, :age1).from(19).to(nil) @@ -2099,7 +2128,7 @@ RSpec.describe LettingsLog do end context "when the question type has answer options" do - let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, illness: 1, illness_type_1: 1) } + let(:lettings_log) { create(:lettings_log, :in_progress, illness: 1, illness_type_1: 1) } it "clears the answer" do expect { lettings_log.update!(illness: 2) }.to change(lettings_log, :illness_type_1).from(1).to(nil) @@ -2108,7 +2137,7 @@ RSpec.describe LettingsLog do end context "with two pages having the same question key, only one's dependency is met" do - let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, cbl: 0, preg_occ: 2, wchair: 2) } + let(:lettings_log) { create(:lettings_log, :in_progress, cbl: 0, preg_occ: 2, wchair: 2) } it "does not clear the value for answers that apply to both pages" do expect(lettings_log.cbl).to eq(0) @@ -2123,7 +2152,7 @@ RSpec.describe LettingsLog do end context "when a non select question associated with several pages is routed to" do - let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, period: 2, needstype: 1, renewal: 0) } + let(:lettings_log) { create(:lettings_log, :in_progress, period: 2, needstype: 1, renewal: 0) } it "does not clear the answer value" do lettings_log.update!({ unitletas: 1 }) @@ -2133,7 +2162,7 @@ RSpec.describe LettingsLog do end context "when the lettings log does not have a valid form set yet" do - let(:lettings_log) { FactoryBot.create(:lettings_log) } + let(:lettings_log) { create(:lettings_log) } it "does not throw an error" do expect { lettings_log.update(startdate: Time.zone.local(2015, 1, 1)) }.not_to raise_error @@ -2141,7 +2170,7 @@ RSpec.describe LettingsLog do end context "when it changes from a renewal to not a renewal" do - let(:lettings_log) { FactoryBot.create(:lettings_log) } + let(:lettings_log) { create(:lettings_log) } it "resets inferred waityear value" do lettings_log.update!({ renewal: 1 }) @@ -2173,8 +2202,8 @@ RSpec.describe LettingsLog do end context "when it changes from a supported housing to not a supported housing" do - let(:location) { FactoryBot.create(:location, mobility_type: "A", postcode: "SW1P 4DG") } - let(:lettings_log) { FactoryBot.create(:lettings_log, location:) } + let(:location) { create(:location, mobility_type: "A", postcode: "SW1P 4DG") } + let(:lettings_log) { create(:lettings_log, location:) } it "resets inferred wchair value" do lettings_log.update!({ needstype: 2 }) @@ -2203,7 +2232,7 @@ RSpec.describe LettingsLog do end context "when it is not a renewal" do - let(:lettings_log) { FactoryBot.create(:lettings_log) } + let(:lettings_log) { create(:lettings_log) } it "saves waityear value" do lettings_log.update!({ renewal: 0, waityear: 2 }) @@ -2215,13 +2244,13 @@ RSpec.describe LettingsLog do end context "when a support user changes the owning organisation of the log" do - let(:lettings_log) { FactoryBot.create(:lettings_log, created_by: created_by_user) } - let(:organisation_2) { FactoryBot.create(:organisation) } + let(:lettings_log) { create(:lettings_log, created_by: created_by_user) } + let(:organisation_2) { create(:organisation) } context "when the organisation selected doesn't match the scheme set" do - let(:scheme) { FactoryBot.create(:scheme, owning_organisation: created_by_user.organisation) } - let(:location) { FactoryBot.create(:location, scheme:) } - let(:lettings_log) { FactoryBot.create(:lettings_log, owning_organisation: nil, needstype: 2, scheme_id: scheme.id) } + let(:scheme) { create(:scheme, owning_organisation: created_by_user.organisation) } + let(:location) { create(:location, scheme:) } + let(:lettings_log) { create(:lettings_log, owning_organisation: nil, needstype: 2, scheme_id: scheme.id) } it "clears the scheme value" do lettings_log.update!(owning_organisation: organisation_2) @@ -2230,9 +2259,9 @@ RSpec.describe LettingsLog do end context "when the organisation selected still matches the scheme set" do - let(:scheme) { FactoryBot.create(:scheme, owning_organisation: organisation_2) } - let(:location) { FactoryBot.create(:location, scheme:) } - let(:lettings_log) { FactoryBot.create(:lettings_log, owning_organisation: nil, needstype: 2, scheme_id: scheme.id) } + let(:scheme) { create(:scheme, owning_organisation: organisation_2) } + let(:location) { create(:location, scheme:) } + let(:lettings_log) { create(:lettings_log, owning_organisation: nil, needstype: 2, scheme_id: scheme.id) } it "does not clear the scheme value" do lettings_log.update!(owning_organisation: organisation_2) @@ -2319,7 +2348,7 @@ RSpec.describe LettingsLog do describe "tshortfall_unknown?" do context "when tshortfall is nil" do - let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, tshortfall_known: nil) } + let(:lettings_log) { create(:lettings_log, :in_progress, tshortfall_known: nil) } it "returns false" do expect(lettings_log.tshortfall_unknown?).to be false @@ -2327,7 +2356,7 @@ RSpec.describe LettingsLog do end context "when tshortfall is No" do - let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, tshortfall_known: 1) } + let(:lettings_log) { create(:lettings_log, :in_progress, tshortfall_known: 1) } it "returns false" do expect(lettings_log.tshortfall_unknown?).to be true @@ -2335,7 +2364,7 @@ RSpec.describe LettingsLog do end context "when tshortfall is Yes" do - let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, tshortfall_known: 0) } + let(:lettings_log) { create(:lettings_log, :in_progress, tshortfall_known: 0) } it "returns false" do expect(lettings_log.tshortfall_unknown?).to be false @@ -2344,7 +2373,7 @@ RSpec.describe LettingsLog do end describe "paper trail" do - let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress) } + let(:lettings_log) { create(:lettings_log, :in_progress) } it "creates a record of changes to a log" do expect { lettings_log.update!(age1: 64) }.to change(lettings_log.versions, :count).by(1) @@ -2357,7 +2386,7 @@ RSpec.describe LettingsLog do end describe "soft values for period" do - let(:lettings_log) { FactoryBot.create(:lettings_log) } + let(:lettings_log) { create(:lettings_log) } before do LaRentRange.create!( @@ -2404,12 +2433,12 @@ RSpec.describe LettingsLog do end describe "scopes" do - let!(:lettings_log_1) { FactoryBot.create(:lettings_log, :in_progress, startdate: Time.utc(2021, 5, 3), created_by: created_by_user) } - let!(:lettings_log_2) { FactoryBot.create(:lettings_log, :completed, startdate: Time.utc(2021, 5, 3), created_by: created_by_user) } + let!(:lettings_log_1) { create(:lettings_log, :in_progress, startdate: Time.utc(2021, 5, 3), created_by: created_by_user) } + let!(:lettings_log_2) { create(:lettings_log, :completed, startdate: Time.utc(2021, 5, 3), created_by: created_by_user) } before do Timecop.freeze(Time.utc(2022, 6, 3)) - FactoryBot.create(:lettings_log, startdate: Time.utc(2022, 6, 3)) + create(:lettings_log, startdate: Time.utc(2022, 6, 3)) end after do @@ -2417,10 +2446,10 @@ RSpec.describe LettingsLog do end context "when searching logs" do - let!(:lettings_log_to_search) { FactoryBot.create(:lettings_log, :completed) } + let!(:lettings_log_to_search) { create(:lettings_log, :completed) } before do - FactoryBot.create_list(:lettings_log, 5, :completed) + create_list(:lettings_log, 5, :completed) end describe "#filter_by_id" do @@ -2475,7 +2504,7 @@ RSpec.describe LettingsLog do end context "when lettings log is supported housing" do - let(:location) { FactoryBot.create(:location, postcode: "W6 0ST") } + let(:location) { create(:location, postcode: "W6 0ST") } before do lettings_log_to_search.update!(needstype: 2, location:) @@ -2515,7 +2544,7 @@ RSpec.describe LettingsLog do end context "when lettings log is supported housing" do - let(:location) { FactoryBot.create(:location, postcode: "W6 0ST") } + let(:location) { create(:location, postcode: "W6 0ST") } before do lettings_log_to_search.update!(needstype: 2, location:) @@ -2573,15 +2602,15 @@ RSpec.describe LettingsLog do end context "when filtering by organisation" do - let(:organisation_1) { FactoryBot.create(:organisation) } - let(:organisation_2) { FactoryBot.create(:organisation) } - let(:organisation_3) { FactoryBot.create(:organisation) } + let(:organisation_1) { create(:organisation) } + let(:organisation_2) { create(:organisation) } + let(:organisation_3) { create(:organisation) } before do - FactoryBot.create(:lettings_log, :in_progress, owning_organisation: organisation_1, managing_organisation: organisation_1, created_by: nil) - FactoryBot.create(:lettings_log, :completed, owning_organisation: organisation_1, managing_organisation: organisation_2, created_by: nil) - FactoryBot.create(:lettings_log, :completed, owning_organisation: organisation_2, managing_organisation: organisation_1, created_by: nil) - FactoryBot.create(:lettings_log, :completed, owning_organisation: organisation_2, managing_organisation: organisation_2, created_by: nil) + create(:lettings_log, :in_progress, owning_organisation: organisation_1, managing_organisation: organisation_1, created_by: nil) + create(:lettings_log, :completed, owning_organisation: organisation_1, managing_organisation: organisation_2, created_by: nil) + create(:lettings_log, :completed, owning_organisation: organisation_2, managing_organisation: organisation_1, created_by: nil) + create(:lettings_log, :completed, owning_organisation: organisation_2, managing_organisation: organisation_2, created_by: nil) end it "filters by given organisation" do @@ -2623,7 +2652,7 @@ RSpec.describe LettingsLog do describe "#retirement_age_for_person" do context "when a person gender is Male" do - let(:lettings_log) { FactoryBot.build(:lettings_log, sex1: "M") } + let(:lettings_log) { build(:lettings_log, sex1: "M") } it "returns the expected retirement age" do expect(lettings_log.retirement_age_for_person_1).to eq(67) @@ -2635,7 +2664,7 @@ RSpec.describe LettingsLog do end context "when a person gender is Female" do - let(:lettings_log) { FactoryBot.build(:lettings_log, sex2: "F") } + let(:lettings_log) { build(:lettings_log, sex2: "F") } it "returns the expected retirement age" do expect(lettings_log.retirement_age_for_person_2).to eq(60) @@ -2647,7 +2676,7 @@ RSpec.describe LettingsLog do end context "when a person gender is Non-Binary" do - let(:lettings_log) { FactoryBot.build(:lettings_log, sex3: "X") } + let(:lettings_log) { build(:lettings_log, sex3: "X") } it "returns the expected retirement age" do expect(lettings_log.retirement_age_for_person_3).to eq(67) @@ -2659,7 +2688,7 @@ RSpec.describe LettingsLog do end context "when the person gender is not set" do - let(:lettings_log) { FactoryBot.build(:lettings_log) } + let(:lettings_log) { build(:lettings_log) } it "returns nil" do expect(lettings_log.retirement_age_for_person_3).to be_nil @@ -2671,7 +2700,7 @@ RSpec.describe LettingsLog do end context "when a postcode contains unicode characters" do - let(:lettings_log) { FactoryBot.build(:lettings_log, postcode_full: "SR81LS\u00A0") } + let(:lettings_log) { build(:lettings_log, postcode_full: "SR81LS\u00A0") } it "triggers a validation error" do expect { lettings_log.save! }.to raise_error(ActiveRecord::RecordInvalid, /Enter a postcode in the correct format/) @@ -2680,9 +2709,9 @@ RSpec.describe LettingsLog do end describe "csv download" do - let(:scheme) { FactoryBot.create(:scheme) } - let(:location) { FactoryBot.create(:location, :export, scheme:, type_of_unit: 6, postcode: "SE11TE", startdate: Time.zone.local(2021, 10, 1)) } - let(:user) { FactoryBot.create(:user, organisation: location.scheme.owning_organisation) } + let(:scheme) { create(:scheme) } + let(:location) { create(:location, :export, scheme:, type_of_unit: 6, postcode: "SE11TE", startdate: Time.zone.local(2021, 10, 1)) } + let(:user) { create(:user, organisation: location.scheme.owning_organisation) } let(:expected_content) { csv_export_file.read } after do diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index e8798b145..6e1a98877 100644 --- a/spec/models/sales_log_spec.rb +++ b/spec/models/sales_log_spec.rb @@ -36,7 +36,7 @@ RSpec.describe SalesLog, type: :model do end describe "#update" do - let(:sales_log) { FactoryBot.create(:sales_log, created_by: created_by_user) } + let(:sales_log) { create(:sales_log, created_by: created_by_user) } let(:validator) { sales_log._validators[nil].first } after do @@ -49,10 +49,34 @@ RSpec.describe SalesLog, type: :model do end describe "#optional_fields" do - let(:sales_log) { build(:sales_log) } + context "when saledate is before 2023" do + let(:sales_log) { build(:sales_log, saledate: Time.zone.parse("2022-07-01")) } it "returns optional fields" do - expect(sales_log.optional_fields).to eq(%w[saledate_check purchid monthly_charges_value_check old_persons_shared_ownership_value_check]) + expect(sales_log.optional_fields).to eq(%w[ + saledate_check + purchid + monthly_charges_value_check + old_persons_shared_ownership_value_check + proplen + ]) + end + end + + context "when saledate is after 2023" do + let(:sales_log) { build(:sales_log, saledate: Time.zone.parse("2023-07-01")) } + + it "returns optional fields" do + expect(sales_log.optional_fields).to eq(%w[ + saledate_check + purchid + monthly_charges_value_check + old_persons_shared_ownership_value_check + address_line2 + county + postcode_full + ]) + end end end @@ -135,7 +159,7 @@ RSpec.describe SalesLog, type: :model do end describe "derived variables" do - let(:sales_log) { FactoryBot.create(:sales_log, :completed) } + let(:sales_log) { create(:sales_log, :completed) } it "correctly derives and saves exday, exmonth and exyear" do sales_log.update!(exdate: Time.gm(2022, 5, 4), saledate: Time.gm(2022, 7, 4), ownershipsch: 1, staircase: 2, resale: 2) @@ -192,7 +216,7 @@ RSpec.describe SalesLog, type: :model do end let!(:address_sales_log) do - FactoryBot.create( + create( :sales_log, :completed, owning_organisation:, @@ -336,7 +360,7 @@ RSpec.describe SalesLog, type: :model do context "when deriving household variables" do let!(:sales_log) do - FactoryBot.create( + create( :sales_log, :completed, jointpur: 1, @@ -463,7 +487,7 @@ RSpec.describe SalesLog, type: :model do end describe "#field_formatted_as_currency" do - let(:completed_sales_log) { FactoryBot.create(:sales_log, :completed) } + let(:completed_sales_log) { create(:sales_log, :completed) } it "returns small numbers correctly formatted as currency" do completed_sales_log.update!(savings: 4)