Browse Source

Always show 'your org' to non support users

CLDC-20-more-ac-fixes3
Jack S 2 years ago
parent
commit
e9a335f7d1
  1. 2
      app/models/form/lettings/questions/managing_organisation.rb
  2. 21
      spec/models/form/lettings/questions/managing_organisation_spec.rb

2
app/models/form/lettings/questions/managing_organisation.rb

@ -21,7 +21,7 @@ class Form::Lettings::Questions::ManagingOrganisation < ::Form::Question
if log.owning_organisation.holds_own_stock? if log.owning_organisation.holds_own_stock?
opts[log.owning_organisation.id] = "#{log.owning_organisation.name} (Owning organisation)" opts[log.owning_organisation.id] = "#{log.owning_organisation.name} (Owning organisation)"
end end
elsif current_user.organisation.holds_own_stock? else
opts[current_user.organisation.id] = "#{current_user.organisation.name} (Your organisation)" opts[current_user.organisation.id] = "#{current_user.organisation.name} (Your organisation)"
end end

21
spec/models/form/lettings/questions/managing_organisation_spec.rb

@ -73,6 +73,27 @@ RSpec.describe Form::Lettings::Questions::ManagingOrganisation, type: :model do
end end
end end
context "when user not support and does not own stock" do
let(:user) { create(:user, :data_coordinator, organisation: create(:organisation, holds_own_stock: false)) }
let(:log) { create(:lettings_log) }
let!(:org_rel1) { create(:organisation_relationship, :managing, parent_organisation: user.organisation) }
let!(:org_rel2) { create(:organisation_relationship, :managing, parent_organisation: user.organisation) }
let(:options) do
{
"" => "Select an option",
user.organisation.id => "#{user.organisation.name} (Your organisation)",
org_rel1.child_organisation.id => org_rel1.child_organisation.name,
org_rel2.child_organisation.id => org_rel2.child_organisation.name,
}
end
it "shows managing agents with own org at the top" do
expect(question.displayed_answer_options(log, user)).to eq(options)
end
end
context "when support user and org does not own own stock" do context "when support user and org does not own own stock" do
let(:user) { create(:user, :support) } let(:user) { create(:user, :support) }
let(:log_owning_org) { create(:organisation, holds_own_stock: false) } let(:log_owning_org) { create(:organisation, holds_own_stock: false) }

Loading…
Cancel
Save