Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing 'storages' association on Datacenter #23252

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/ems_folder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class EmsFolder < ApplicationRecord
virtual_has_many :vms, :uses => :all_relationships
virtual_has_many :miq_templates, :uses => :all_relationships
virtual_has_many :hosts, :uses => :all_relationships
virtual_has_many :storages, :uses => :all_relationships

virtual_attribute :folder_path, :string, :uses => :all_relationships

Expand Down
17 changes: 17 additions & 0 deletions spec/models/miq_request_workflow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,23 @@
expect(workflow.allowed_storages.map(&:id)).to eq([storage_2.id])
end
end

context "with a user with a belongs_to_filter" do
before do
group = workflow.requester.miq_groups.first
group.entitlement = Entitlement.new
group.entitlement.set_managed_filters([])
group.entitlement.set_belongsto_filters(["/belongsto/ExtManagementSystem|#{ems.name}/EmsFolder|Datacenters"])
group.save!
end

it "filters out storages" do
allow(workflow).to receive(:get_source_and_targets).and_return(:ems => workflow.ci_to_hash_struct(ems))
allow(workflow).to receive(:allowed_hosts_obj).and_return([host])

expect(workflow.allowed_storages.map(&:id)).to be_empty
end
end
end

context "with read-only storages" do
Expand Down