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

Add option to clear classifications for tag_details #17465

Merged
merged 3 commits into from
May 30, 2018
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
3 changes: 3 additions & 0 deletions lib/miq_expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,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 @@ -3340,6 +3340,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