Skip to content

Commit

Permalink
Merge pull request #8304 from h-kataria/catalogs_tree_fix
Browse files Browse the repository at this point in the history
Do not show items not marked to be displayed in Catalog in tree
  • Loading branch information
Dan Clarizio committed Apr 28, 2016
2 parents 91b798c + 54c6fdb commit 5cf41f2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_service_catalog.rb
Expand Up @@ -25,7 +25,7 @@ def x_get_tree_roots(count_only, _options)
end

def x_get_tree_stc_kids(object, count_only)
objects = rbac_filtered_objects(object.service_templates.sort_by { |o| o.name.downcase })
objects = rbac_filtered_objects(object.service_templates.select(&:display))
count_only_or_objects(count_only, objects, 'name')
end

Expand Down
27 changes: 27 additions & 0 deletions spec/presenters/tree_builder_service_catalog_spec.rb
@@ -0,0 +1,27 @@
describe TreeBuilderServiceCatalog do
include CompressedIds
before do
Tenant.seed
@catalog = FactoryGirl.create(:service_template_catalog, :name => "My Catalog")
FactoryGirl.create(:service_template,
:name => "Display in Catalog",
:service_template_catalog => @catalog,
:display => true)
FactoryGirl.create(:service_template,
:name => "Do not Display in Catalog",
:service_template_catalog => @catalog,
:display => false)
@tree = TreeBuilderServiceCatalog.new(:svccat_tree, "svccat", {})
end

it "#x_get_tree_roots" do
roots = @tree.send(:x_get_tree_roots, false, {})
expect(roots.first.name).to eq(@catalog.name)
end

it "#x_get_tree_stc_kids returns items that are set to be displayed in catalog" do
items = @tree.send(:x_get_tree_stc_kids, @catalog, false)
expect(items.size).to eq(1)
expect(items.first.name).to eq("Display in Catalog")
end
end

0 comments on commit 5cf41f2

Please sign in to comment.