Skip to content

Commit

Permalink
Merge pull request #17465 from lgalis/add_option_to_clear_classificat…
Browse files Browse the repository at this point in the history
…ions

Add option to clear classifications for tag_details
(cherry picked from commit e5adfd2)

https://bugzilla.redhat.com/show_bug.cgi?id=1591495
  • Loading branch information
gtanzillo authored and simaishi committed Jul 11, 2018
1 parent fbb84f0 commit 6878a3a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/miq_expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,9 @@ def self._model_details(relats, opts)

def self.tag_details(path, opts)
result = []
if opts[:no_cache]
@classifications = nil
end
@classifications ||= categories
@classifications.each do |name, cat|
prefix = path.nil? ? "managed" : [path, "managed"].join(".")
Expand Down
17 changes: 17 additions & 0 deletions spec/lib/miq_expression_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3356,6 +3356,23 @@
actual = described_class.tag_details(nil, {})
expect(actual).to eq([["My Company Tags : Environment", "managed-env"]])
end

it "returns the added classification when no_cache option is used" do
Tenant.seed
FactoryGirl.create(:classification,
:name => "first_classification",
:description => "First Classification",
:children => [FactoryGirl.create(:classification)])
actual = described_class.tag_details(nil, {})
expect(actual).to eq([["My Company Tags : First Classification", "managed-first_classification"]])

FactoryGirl.create(:classification,
:name => "second_classification",
:description => "Second Classification",
:children => [FactoryGirl.create(:classification)])
actual = described_class.tag_details(nil, :no_cache => true)
expect(actual).to eq([["My Company Tags : First Classification", "managed-first_classification"], ["My Company Tags : Second Classification", "managed-second_classification"]])
end
end

describe "miq_adv_search_lists" do
Expand Down

0 comments on commit 6878a3a

Please sign in to comment.