Browse Source

Do not infer managing org

CLDC-20-more-ac-fixes3
Jack S 2 years ago
parent
commit
4dc96337f3
  1. 9
      app/models/form/lettings/pages/managing_organisation.rb
  2. 40
      spec/models/form/lettings/pages/managing_organisation_spec.rb

9
app/models/form/lettings/pages/managing_organisation.rb

@ -25,13 +25,6 @@ class Form::Lettings::Pages::ManagingOrganisation < ::Form::Page
return false unless organisation
return true unless organisation.holds_own_stock?
managing_agents = organisation.managing_agents
return false if managing_agents.count.zero?
return true if managing_agents.count > 1
log.update!(managing_organisation: managing_agents.first)
false
organisation.managing_agents.count > 1
end
end

40
spec/models/form/lettings/pages/managing_organisation_spec.rb

@ -40,10 +40,6 @@ RSpec.describe Form::Lettings::Pages::ManagingOrganisation, type: :model do
it "is not shown" do
expect(page.routed_to?(log, nil)).to eq(false)
end
it "does not update managing_organisation_id" do
expect { page.routed_to?(log, nil) }.not_to change(log.reload, :managing_organisation)
end
end
context "when support" do
@ -56,10 +52,6 @@ RSpec.describe Form::Lettings::Pages::ManagingOrganisation, type: :model do
it "is shown" do
expect(page.routed_to?(log, user)).to eq(true)
end
it "does not update managing_organisation_id" do
expect { page.routed_to?(log, user) }.not_to change(log.reload, :managing_organisation)
end
end
context "when owning_organisation not set" do
@ -69,10 +61,6 @@ RSpec.describe Form::Lettings::Pages::ManagingOrganisation, type: :model do
it "is not shown" do
expect(page.routed_to?(log, user)).to eq(false)
end
it "does not update managing_organisation_id" do
expect { page.routed_to?(log, user) }.not_to change(log.reload, :managing_organisation)
end
end
context "when holds own stock" do
@ -84,10 +72,6 @@ RSpec.describe Form::Lettings::Pages::ManagingOrganisation, type: :model do
it "is not shown" do
expect(page.routed_to?(log, user)).to eq(false)
end
it "does not update managing_organisation_id" do
expect { page.routed_to?(log, user) }.not_to change(log.reload, :managing_organisation)
end
end
context "with >1 managing_agents" do
@ -99,10 +83,6 @@ RSpec.describe Form::Lettings::Pages::ManagingOrganisation, type: :model do
it "is shown" do
expect(page.routed_to?(log, user)).to eq(true)
end
it "does not update managing_organisation_id" do
expect { page.routed_to?(log, user) }.not_to change(log.reload, :managing_organisation)
end
end
context "with 1 managing_agents" do
@ -120,10 +100,6 @@ RSpec.describe Form::Lettings::Pages::ManagingOrganisation, type: :model do
it "is not shown" do
expect(page.routed_to?(log, user)).to eq(false)
end
it "updates managing_organisation_id" do
expect { page.routed_to?(log, user) }.to change(log.reload, :managing_organisation).to(managing_agent)
end
end
end
end
@ -137,10 +113,6 @@ RSpec.describe Form::Lettings::Pages::ManagingOrganisation, type: :model do
it "is shown" do
expect(page.routed_to?(log, user)).to eq(true)
end
it "does not update managing_organisation_id" do
expect { page.routed_to?(log, user) }.not_to change(log.reload, :managing_organisation)
end
end
context "when holds own stock" do
@ -152,10 +124,6 @@ RSpec.describe Form::Lettings::Pages::ManagingOrganisation, type: :model do
it "is not shown" do
expect(page.routed_to?(log, user)).to eq(false)
end
it "does not update managing_organisation_id" do
expect { page.routed_to?(log, user) }.not_to change(log.reload, :managing_organisation)
end
end
context "with >1 managing_agents" do
@ -167,10 +135,6 @@ RSpec.describe Form::Lettings::Pages::ManagingOrganisation, type: :model do
it "is shown" do
expect(page.routed_to?(log, user)).to eq(true)
end
it "does not update managing_organisation_id" do
expect { page.routed_to?(log, user) }.not_to change(log.reload, :managing_organisation)
end
end
context "with 1 managing_agents" do
@ -188,10 +152,6 @@ RSpec.describe Form::Lettings::Pages::ManagingOrganisation, type: :model do
it "is not shown" do
expect(page.routed_to?(log, user)).to eq(false)
end
it "updates managing_organisation_id" do
expect { page.routed_to?(log, user) }.to change(log.reload, :managing_organisation).to(managing_agent)
end
end
end
end

Loading…
Cancel
Save