Skip to content

Commit

Permalink
Fixed call in tree_add_child_nodes method to use TreeBuilder methods
Browse files Browse the repository at this point in the history
  • Loading branch information
h-kataria committed Nov 2, 2015
1 parent 3f219bb commit a7686ec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/application_controller/explorer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ def x_build_node_id(object, pid = nil, options = {})

# Add the children of a node that is being expanded (autoloaded), called by generic tree_autoload method
def tree_add_child_nodes(id)
TreeBuilder.x_get_child_nodes(id)
TreeBuilder.tree_add_child_nodes(@sb,
x_tree[:klass_name],
id)
end

def rbac_filtered_objects(objects, options = {})
Expand Down
22 changes: 22 additions & 0 deletions spec/controllers/application_controller/explorer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,25 @@ def make_item(i)
end
end
end

describe ReportController do
context '#tree_add_child_nodes' do
it 'calls tree_add_child_nodes TreeBuilder method' do
widget = FactoryGirl.create(:miq_widget, :description => "Foo", :title => "Foo", :content_type => "report")
controller.instance_variable_set(:@sb,
:trees => {:widgets_tree => {:active_node => "root",
:klass_name => "TreeBuilderReportWidgets",
:open_nodes => []}},
:active_tree => :widgets_tree

)
TreeBuilderReportWidgets.new('widgets_tree', 'widgets', {})
nodes = controller.send(:tree_add_child_nodes, 'xx-r')
nodes.should eq([{:key => "-#{controller.to_cid(widget.id)}",
:title => "Foo",
:icon => "report_widget.png",
:tooltip => "Foo"}]
)
end
end
end

0 comments on commit a7686ec

Please sign in to comment.