Skip to content

Commit

Permalink
Use provider_active_tree? method in provider_foreman controller
Browse files Browse the repository at this point in the history
  • Loading branch information
hstastna committed Jan 8, 2020
1 parent 3f83e5a commit 65155b5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/provider_foreman_controller.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
25 changes: 25 additions & 0 deletions spec/controllers/provider_foreman_controller_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down

0 comments on commit 65155b5

Please sign in to comment.