diff --git a/spec/features/lettings_log_spec.rb b/spec/features/lettings_log_spec.rb index b9ad58b3d..4a3942fec 100644 --- a/spec/features/lettings_log_spec.rb +++ b/spec/features/lettings_log_spec.rb @@ -286,8 +286,8 @@ RSpec.describe "Lettings Log Features" do end context "when the current user's organisation does hold stock" do - let!(:owning_org1) { create(:organisation, name: "Owning org 1") } - let!(:org_rel1) { create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: owning_org1) } + let!(:owning_org) { create(:organisation, name: "Owning org") } + let!(:org_rel1) { create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: owning_org) } before do user.organisation.update!(holds_own_stock: true) @@ -300,7 +300,7 @@ RSpec.describe "Lettings Log Features" do click_link("Set up this lettings log") log_id = page.current_path.scan(/\d/).join expect(page).to have_current_path("/lettings-logs/#{log_id}/stock-owner") - select(owning_org1.name, from: "lettings-log-owning-organisation-id-field") + select(owning_org.name, from: "lettings-log-owning-organisation-id-field") click_button("Save and continue") expect(page).not_to have_current_path("/lettings-logs/#{log_id}/managing-organisation") visit("lettings-logs/#{log_id}/setup/check-answers") @@ -311,22 +311,22 @@ RSpec.describe "Lettings Log Features" do context "and the user's organisation has 1 or more managing agents" do let(:managing_org) { create(:organisation, name: "Managing org") } - let!(:org_rel) { create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: managing_org) } + let!(:org_rel2) { create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: managing_org) } it "does show the managing organisation question" do visit("/lettings-logs") click_button("Create a new lettings log") click_link("Set up this lettings log") log_id = page.current_path.scan(/\d/).join - if page.current_path == "/lettings-logs/#{log_id}/owning-organisation" - click_link("Skip for now") - end + expect(page).to have_current_path("/lettings-logs/#{log_id}/stock-owner") + select(user.organisation.name, from: "lettings-log-owning-organisation-id-field") + click_button("Save and continue") expect(page).to have_current_path("/lettings-logs/#{log_id}/managing-organisation") select(managing_org.name, from: "lettings-log-managing-organisation-id-field") click_button("Save and continue") visit("lettings-logs/#{log_id}/setup/check-answers") expect(page).to have_content("Managing agent Managing org") - expect(user.organisation.managing_agents).to eq([org_rel.child_organisation]) + expect(user.organisation.managing_agents).to eq([org_rel2.child_organisation]) end end end