From f5a04382e8447fbeffdd38528bf2cf949a82862f Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Thu, 23 Mar 2023 13:35:46 +0000 Subject: [PATCH] feat: fix more tests --- spec/helpers/locations_helper_spec.rb | 2 +- spec/models/form/lettings/questions/scheme_id_spec.rb | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/helpers/locations_helper_spec.rb b/spec/helpers/locations_helper_spec.rb index ae63c2e84..91457898c 100644 --- a/spec/helpers/locations_helper_spec.rb +++ b/spec/helpers/locations_helper_spec.rb @@ -178,7 +178,7 @@ RSpec.describe LocationsHelper do context "when location has no local authority" do before do LocalAuthorityLink.create!(local_authority_id: LocalAuthority.find_by(code: "E07000030").id, linked_local_authority_id: LocalAuthority.find_by(code: "E06000063").id) - location.update!(location_code: nil) + location.update!(location_code: nil, confirmed: false) end it "returns correct display attributes" do diff --git a/spec/models/form/lettings/questions/scheme_id_spec.rb b/spec/models/form/lettings/questions/scheme_id_spec.rb index a1337f408..3289db4b9 100644 --- a/spec/models/form/lettings/questions/scheme_id_spec.rb +++ b/spec/models/form/lettings/questions/scheme_id_spec.rb @@ -44,7 +44,6 @@ RSpec.describe Form::Lettings::Questions::SchemeId, type: :model do let(:organisation_2) { FactoryBot.create(:organisation) } let(:user) { FactoryBot.create(:user, organisation:) } let(:scheme) { FactoryBot.create(:scheme, owning_organisation: organisation) } - let!(:location) { FactoryBot.create(:location, scheme:) } let(:lettings_log) { FactoryBot.create(:lettings_log, created_by: user, needstype: 2) } before do @@ -52,9 +51,7 @@ RSpec.describe Form::Lettings::Questions::SchemeId, type: :model do end context "when a scheme with at least 1 location exists" do - before do - FactoryBot.create(:location, scheme:) - end + let!(:location) { FactoryBot.create(:location, scheme:) } it "has the correct answer_options based on the schemes the user's organisation owns or manages" do expected_answer = { "" => "Select an option", scheme.id.to_s => scheme } @@ -85,6 +82,8 @@ RSpec.describe Form::Lettings::Questions::SchemeId, type: :model do end context "when the question is answered" do + let!(:location) { FactoryBot.create(:location, scheme:) } + it "returns scheme as selected answer" do lettings_log.update!(scheme:) answers = question.displayed_answer_options(lettings_log).map do |key, value|