Browse Source

feat: fix more tests

pull/1455/head
natdeanlewissoftwire 3 years ago
parent
commit
f5a04382e8
  1. 2
      spec/helpers/locations_helper_spec.rb
  2. 7
      spec/models/form/lettings/questions/scheme_id_spec.rb

2
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

7
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|

Loading…
Cancel
Save