|
|
@ -132,30 +132,6 @@ RSpec.describe "Lettings Log Features" do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when the owning organisation question is answered" do |
|
|
|
context "when the owning organisation question is answered" do |
|
|
|
context "and the owning organisation doesn't hold stock" do |
|
|
|
|
|
|
|
let(:managing_org) { create(:organisation, name: "Managing org") } |
|
|
|
|
|
|
|
let!(:org_rel) { create(:organisation_relationship, parent_organisation: support_user.organisation, child_organisation: managing_org) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
support_user.organisation.update!(holds_own_stock: false) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "shows 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 |
|
|
|
|
|
|
|
select(support_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", normalize_ws: true) |
|
|
|
|
|
|
|
expect(support_user.organisation.managing_agents).to eq([org_rel.child_organisation]) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "and the owning organisation does hold stock" do |
|
|
|
context "and the owning organisation does hold stock" do |
|
|
|
before do |
|
|
|
before do |
|
|
|
support_user.organisation.update!(holds_own_stock: true) |
|
|
|
support_user.organisation.update!(holds_own_stock: true) |
|
|
|