From f377bc0c16145caa85564f13187707a712cf7588 Mon Sep 17 00:00:00 2001 From: Sam Seed Date: Thu, 5 Jan 2023 10:57:38 +0000 Subject: [PATCH] test: check housing prov. still selectable after deleting relationship --- .../form/lettings/questions/stock_owner_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/models/form/lettings/questions/stock_owner_spec.rb b/spec/models/form/lettings/questions/stock_owner_spec.rb index 11ba7a2f5..8babebbd7 100644 --- a/spec/models/form/lettings/questions/stock_owner_spec.rb +++ b/spec/models/form/lettings/questions/stock_owner_spec.rb @@ -64,6 +64,22 @@ RSpec.describe Form::Lettings::Questions::StockOwner, type: :model do user.organisation.update!(holds_own_stock: true) expect(question.displayed_answer_options(log, user)).to eq(options) end + + context "when the owning-managing organisation relationship is deleted" do + let(:options) do + { + "" => "Select an option", + user.organisation.id => "User org (Your organisation)", + owning_org_2.id => "Owning org 2" + } + end + it "doesn't remove the housing provider from the list of allowed housing providers" do + log.update!(owning_organisation: owning_org_2) + expect(question.displayed_answer_options(log, user)).to eq(options) + org_rel.destroy! + expect(question.displayed_answer_options(log, user)).to eq(options) + end + end end context "when user's org doesn't own stock" do