Skip to content

Commit

Permalink
Remove nil elements from top_nodes array.
Browse files Browse the repository at this point in the history
Even when section was skipped in x_get_tree_roots method a nil was being added to top_nodes array that was causing undefined method `new' for nil:NilClass
in /app/presenters/tree_node.rb:9. This fix removes any nil elements from array before trying to build RBAC features tree.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1533391
  • Loading branch information
h-kataria committed Jan 12, 2018
1 parent e6aac4d commit 1c21e1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions app/presenters/tree_builder_ops_rbac_features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def x_get_tree_roots(count_only = false, _options)
%w(all_vm_rules api_exclusive sui).each do |additional_feature|
top_nodes << MiqProductFeature.obj_features[additional_feature][:feature]
end

count_only_or_objects(count_only, top_nodes)
count_only_or_objects(count_only, top_nodes.compact)
end

def x_get_tree_section_kids(parent, count_only = false)
Expand Down
10 changes: 7 additions & 3 deletions spec/presenters/tree_builder_ops_rbac_features_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@
expect(t['checkable']).to be false
end

describe 'main sections' do
%w(aut compute con conf net opt set sto svc vi).each do |i|
describe 'main section keys are excluded from top_nodes if they do not exists in permissions.yml' do
%w(aut compute con conf mdl net opt set sto svc vi).each do |i|
it "includes #{i}" do
expect(main_keys).to include("100000002___tab_#{i}")
if i == 'mdl'
expect(main_keys).not_to include("100000002___tab_#{i}")
else
expect(main_keys).to include("100000002___tab_#{i}")
end
end
end

Expand Down

0 comments on commit 1c21e1b

Please sign in to comment.