From e9681bb0a2009d949c0c153ef92ad6c7ad34b5e3 Mon Sep 17 00:00:00 2001 From: Madhu Kanoor Date: Fri, 7 Apr 2017 11:32:05 -0400 Subject: [PATCH 1/2] Display name and description not getting updated https://bugzilla.redhat.com/show_bug.cgi?id=1440226 In the Namespace object the display name and description attributes were not getting updated. --- .../models/miq_ae_yaml_import.rb | 4 +++- .../models/miq_ae_yaml_import_export_spec.rb | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/miq_automation_engine/models/miq_ae_yaml_import.rb b/lib/miq_automation_engine/models/miq_ae_yaml_import.rb index 369ebaa5faf..72a68ee3274 100644 --- a/lib/miq_automation_engine/models/miq_ae_yaml_import.rb +++ b/lib/miq_automation_engine/models/miq_ae_yaml_import.rb @@ -147,7 +147,7 @@ def import_namespace(namespace_folder, domain_obj, domain_name) process_namespace(domain_obj, namespace_folder, load_file(namespace_file), domain_name) end - def process_namespace(domain_obj, namespace_folder, _namespace_yaml, domain_name) + def process_namespace(domain_obj, namespace_folder, namespace_yaml, domain_name) fqname = if @domain_name == '.' "#{domain_name}/#{namespace_folder}" else @@ -157,6 +157,8 @@ def process_namespace(domain_obj, namespace_folder, _namespace_yaml, domain_name namespace_obj = MiqAeNamespace.find_by_fqname(fqname, false) track_stats('namespace', namespace_obj) namespace_obj ||= add_namespace(fqname) unless @preview + attrs = namespace_yaml.fetch_path('object', 'attributes').slice('display_name', 'description') + namespace_obj.update_attributes(attrs) unless @preview if @options['class_name'] import_class(File.join(namespace_folder, "#{@options['class_name']}#{CLASS_DIR_SUFFIX}"), namespace_obj) else diff --git a/spec/lib/miq_automation_engine/models/miq_ae_yaml_import_export_spec.rb b/spec/lib/miq_automation_engine/models/miq_ae_yaml_import_export_spec.rb index d5f47c9fe16..69064ca9c48 100644 --- a/spec/lib/miq_automation_engine/models/miq_ae_yaml_import_export_spec.rb +++ b/spec/lib/miq_automation_engine/models/miq_ae_yaml_import_export_spec.rb @@ -267,6 +267,17 @@ def add_extra_items_to_customer_domain expect(dom).not_to be_enabled end + + it "check attributes in namespace" do + options = {'yaml_file' => @yaml_file} + assert_single_domain_import(options, options) + dom = MiqAeDomain.find_by_fqname(@customer_domain.name, false) + ns = MiqAeNamespace.find_by(:name => 'customer_namespace_1') + expect(ns.description).to eq("test") + expect(ns.display_name).to eq("test") + end + + it "import single system domain" do options = {'yaml_file' => @yaml_file} @customer_domain.update_attributes(:source => MiqAeDomain::SYSTEM_SOURCE) @@ -733,7 +744,7 @@ def create_fields(class_obj, instance_obj, method_obj) def create_factory_data(domain_name, priority, source = MiqAeDomain::USER_SOURCE) domain = FactoryGirl.create(:miq_ae_domain_enabled, :name => domain_name, :source => source, :priority => priority) - n1 = FactoryGirl.create(:miq_ae_namespace, :name => "#{domain_name}_namespace_1", :parent_id => domain.id) + n1 = FactoryGirl.create(:miq_ae_namespace, :name => "#{domain_name}_namespace_1", :parent_id => domain.id, :description => "test", :display_name => "test") n1_c1 = FactoryGirl.create(:miq_ae_class, :name => "#{domain_name}_test_class_1", :namespace_id => n1.id) n1_1 = FactoryGirl.create(:miq_ae_namespace, :name => "#{domain_name}_namespace_1_1", :parent_id => n1.id) n1_1_c1 = FactoryGirl.create(:miq_ae_class, :name => "#{domain_name}_test_class_4", :namespace_id => n1_1.id) From b08f1f66ac9c4e469931d9fbf3c84059b6e69907 Mon Sep 17 00:00:00 2001 From: Madhu Kanoor Date: Fri, 7 Apr 2017 11:47:50 -0400 Subject: [PATCH 2/2] Rubocop cleanup --- .../models/miq_ae_yaml_import_export_spec.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec/lib/miq_automation_engine/models/miq_ae_yaml_import_export_spec.rb b/spec/lib/miq_automation_engine/models/miq_ae_yaml_import_export_spec.rb index 69064ca9c48..14db1cec7f4 100644 --- a/spec/lib/miq_automation_engine/models/miq_ae_yaml_import_export_spec.rb +++ b/spec/lib/miq_automation_engine/models/miq_ae_yaml_import_export_spec.rb @@ -267,17 +267,14 @@ def add_extra_items_to_customer_domain expect(dom).not_to be_enabled end - it "check attributes in namespace" do options = {'yaml_file' => @yaml_file} assert_single_domain_import(options, options) - dom = MiqAeDomain.find_by_fqname(@customer_domain.name, false) ns = MiqAeNamespace.find_by(:name => 'customer_namespace_1') expect(ns.description).to eq("test") expect(ns.display_name).to eq("test") end - it "import single system domain" do options = {'yaml_file' => @yaml_file} @customer_domain.update_attributes(:source => MiqAeDomain::SYSTEM_SOURCE)