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