diff --git a/app/controllers/provider_foreman_controller.rb b/app/controllers/provider_foreman_controller.rb index 97fbdfa1730..ea327851e70 100644 --- a/app/controllers/provider_foreman_controller.rb +++ b/app/controllers/provider_foreman_controller.rb @@ -96,7 +96,7 @@ def load_or_clear_adv_search self.x_node = params[:id] quick_search_show # User will input the value end - elsif x_active_tree == :configuration_manager_providers_tree && x_node != 'root' # Providers accordion, without Advanced Search + elsif provider_active_tree? && x_node != 'root' # Providers accordion, without Advanced Search listnav_search_selected(0) end end @@ -326,7 +326,7 @@ def configuration_profile_node(id, model) def default_node return unless x_node == "root" - if x_active_tree == :configuration_manager_providers_tree + if provider_active_tree? options = {:model => "ManageIQ::Providers::ConfigurationManager"} @show_list ? process_show_list(options) : options.merge!(update_options) @right_cell_text = _("All Configuration Management Providers") diff --git a/spec/controllers/provider_foreman_controller_spec.rb b/spec/controllers/provider_foreman_controller_spec.rb index df08176274f..d59d1f5c3f1 100644 --- a/spec/controllers/provider_foreman_controller_spec.rb +++ b/spec/controllers/provider_foreman_controller_spec.rb @@ -2,6 +2,7 @@ render_views let(:tags) { ["/managed/quota_max_memory/2048"] } + before do allow(controller).to receive(:data_for_breadcrumbs).and_return({}) @zone = EvmSpecHelper.local_miq_server.zone @@ -738,6 +739,30 @@ end end + describe '#load_or_clear_adv_search' do + before do + allow(controller).to receive(:model_from_active_tree) + controller.instance_variable_set(:@sb, :active_tree => :configuration_manager_providers_tree) + end + + it 'checks if being in a Configuration Manager Providers tree' do + expect(controller).to receive(:provider_active_tree?).and_return(true) + controller.send(:load_or_clear_adv_search) + end + end + + describe '#default_node' do + before do + allow(controller).to receive(:x_node).and_return('root') + controller.instance_variable_set(:@sb, :active_tree => :configuration_manager_providers_tree) + end + + it 'checks if being in a Configuration Manager Providers tree' do + expect(controller).to receive(:provider_active_tree?).and_return(true) + controller.send(:default_node) + end + end + def find_treenode_for_foreman_provider(tree, provider) key = ems_key_for_provider(provider) tree.tree_nodes[0][:nodes]&.find { |c| c[:key] == key }