Skip to content

Commit

Permalink
Merge pull request ManageIQ#19662 from ZitaNemeckova/add_taggable_to_…
Browse files Browse the repository at this point in the history
…pxe_image

Add tags to PxeImage
  • Loading branch information
martinpovolny authored Jan 14, 2020
2 parents 776b041 + 664e150 commit 9a7ab40
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/pxe_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class PxeImage < ApplicationRecord

has_many :customization_templates, :through => :pxe_image_type

acts_as_miq_taggable

before_validation do
if self.default_for_windows_changed? && self.default_for_windows?
pxe_server.pxe_images.where(:default_for_windows => true).update_all(:default_for_windows => false)
Expand Down
1 change: 1 addition & 0 deletions lib/rbac/filterer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Filterer
NetworkRouter
OrchestrationStack
OrchestrationTemplate
PxeImage
ResourcePool
SecurityGroup
Service
Expand Down
18 changes: 18 additions & 0 deletions spec/lib/rbac/filterer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,24 @@ def combine_filtered_ids(user_filtered_ids, belongsto_filtered_ids, managed_filt
tagged_group.save!
end

context 'searching for instances of PxeImage' do
let!(:pxe_image) { FactoryBot.create_list(:pxe_image, 2).first }

before do
pxe_image.tag_with('/managed/environment/prod', :ns => '*')
end

it 'lists only tagged PxeImages' do
results = described_class.search(:class => PxeImage, :user => user).first
expect(results).to match_array [pxe_image]
end

it 'lists only all PxeImages' do
results = described_class.search(:class => PxeImage, :user => admin_user).first
expect(results).to match_array PxeImage.all
end
end

context 'searching for instances of Switches' do
let!(:switch) { FactoryBot.create_list(:switch, 2).first }

Expand Down

0 comments on commit 9a7ab40

Please sign in to comment.