Skip to content

Commit

Permalink
Changes in override, removed unnecessary lines, added missing filter …
Browse files Browse the repository at this point in the history
…in query - read_only
  • Loading branch information
Milan Pospisil committed Dec 20, 2016
1 parent 644ea17 commit 4811281
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
12 changes: 4 additions & 8 deletions app/presenters/tree_builder_miq_action_category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ class TreeBuilderMiqActionCategory < TreeBuilder
private

def override(node, object, _pid, _options)
img = "blank.gif"
leaf = !object.entries.any?
img = "tag.png" unless leaf
node[:image] = ActionController::Base.helpers.image_path("100/#{img}")
node[:title] = object.description
node[:tooltip] = _("Category: %{description}") % {:description => object.description}
leaf = !object.category?
image = leaf ? nil : "100/tag.png"
node[:cfmeNoClick] = !leaf
node[:hideCheckbox] = true
node[:image] = image && ActionController::Base.helpers.image_path(image)
node
end

Expand Down Expand Up @@ -43,7 +39,7 @@ def root_options
# Get root nodes count/array for explorer tree
def x_get_tree_roots(count_only, _options)
cats = Classification.categories.select(&:show)
cats = cats.select { |c| c.entries.any? }
cats = cats.select { |c| c.entries.any? && c.read_only == false }
count_only_or_objects(count_only, cats, :description)
end

Expand Down
12 changes: 0 additions & 12 deletions spec/presenters/tree_builder_miq_action_category_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,10 @@

describe '#override' do
it 'set node' do
desc1 = _("Category: %{description}") % {:description => tag1.description}
desc2 = tag1.description
node = subject.send(:override, {}, tag1, nil, nil)

expect(node[:hideCheckbox]).to eq(true)
expect(node[:tooltip]).to eq(desc1)
expect(node[:title]).to eq(desc2)
expect(node[:cfmeNoClick]).to eq(false)

desc1 = _("Category: %{description}") % {:description => folder1.description}
desc2 = folder1.description
node = subject.send(:override, {}, folder1, nil, nil)

expect(node[:hideCheckbox]).to eq(true)
expect(node[:tooltip]).to eq(desc1)
expect(node[:title]).to eq(desc2)
expect(node[:cfmeNoClick]).to eq(true)
end
end
Expand Down

0 comments on commit 4811281

Please sign in to comment.