From 674909162c46779918ed5e6b96813494d8cbfd5b Mon Sep 17 00:00:00 2001 From: L Galis Date: Tue, 22 May 2018 12:33:15 -0400 Subject: [PATCH 1/3] Add options to clear classifications when calling tag_details --- lib/miq_expression.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/miq_expression.rb b/lib/miq_expression.rb index 40d53428373..283001bb447 100644 --- a/lib/miq_expression.rb +++ b/lib/miq_expression.rb @@ -876,6 +876,9 @@ def self._model_details(relats, opts) def self.tag_details(path, opts) result = [] + if opts[:clear_classifications] + @classifications = nil + end @classifications ||= categories @classifications.each do |name, cat| prefix = path.nil? ? "managed" : [path, "managed"].join(".") From 28fdf7979db435f4de0569f26fe5b4e5006c23e6 Mon Sep 17 00:00:00 2001 From: L Galis Date: Tue, 22 May 2018 12:33:56 -0400 Subject: [PATCH 2/3] Add spec for option to clear classifications when calling tag_details --- spec/lib/miq_expression_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/lib/miq_expression_spec.rb b/spec/lib/miq_expression_spec.rb index fdfc1225f5a..cfa1950a934 100644 --- a/spec/lib/miq_expression_spec.rb +++ b/spec/lib/miq_expression_spec.rb @@ -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 clear_classification 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, :clear_classifications => 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 From 7c44451e1231c99850c017b65290d95d3567dca6 Mon Sep 17 00:00:00 2001 From: L Galis Date: Wed, 30 May 2018 12:53:47 -0400 Subject: [PATCH 3/3] Change option name to no_cache --- lib/miq_expression.rb | 2 +- spec/lib/miq_expression_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/miq_expression.rb b/lib/miq_expression.rb index 283001bb447..b909bc21c47 100644 --- a/lib/miq_expression.rb +++ b/lib/miq_expression.rb @@ -876,7 +876,7 @@ def self._model_details(relats, opts) def self.tag_details(path, opts) result = [] - if opts[:clear_classifications] + if opts[:no_cache] @classifications = nil end @classifications ||= categories diff --git a/spec/lib/miq_expression_spec.rb b/spec/lib/miq_expression_spec.rb index cfa1950a934..8ff07d440f9 100644 --- a/spec/lib/miq_expression_spec.rb +++ b/spec/lib/miq_expression_spec.rb @@ -3341,7 +3341,7 @@ expect(actual).to eq([["My Company Tags : Environment", "managed-env"]]) end - it "returns the added classification when clear_classification option is used" do + it "returns the added classification when no_cache option is used" do Tenant.seed FactoryGirl.create(:classification, :name => "first_classification", @@ -3354,7 +3354,7 @@ :name => "second_classification", :description => "Second Classification", :children => [FactoryGirl.create(:classification)]) - actual = described_class.tag_details(nil, :clear_classifications => true) + 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