diff --git a/spec/presenters/menu/menu_manager_spec.rb b/spec/presenters/menu/menu_manager_spec.rb index a93c92fdabc2..b6e961ba5192 100644 --- a/spec/presenters/menu/menu_manager_spec.rb +++ b/spec/presenters/menu/menu_manager_spec.rb @@ -38,4 +38,15 @@ end end end + + context "menu" do + it "knows about custom items from settings" do + ::Settings.ui.custom_menu = settings_custom_items + count = 0 + Menu::Manager.menu do |item| + count += 1 if item.kind_of?(Menu::Item) && item.name =~ /^Custom Item/ + end + expect(count).to eq(2) + end + end end diff --git a/spec/presenters/menu/settings_loader_spec.rb b/spec/presenters/menu/settings_loader_spec.rb new file mode 100644 index 000000000000..348916bd1b65 --- /dev/null +++ b/spec/presenters/menu/settings_loader_spec.rb @@ -0,0 +1,10 @@ +describe Menu::SettingsLoader do + include Spec::Support::MenuHelper + it "loads custom menu items" do + ::Settings.ui.custom_menu = settings_custom_items + sections, items = described_class.load + + expect(sections.length).to be(0) + expect(items.length).to be(2) + end +end diff --git a/spec/support/menu_helper.rb b/spec/support/menu_helper.rb index b4fb1afecbd4..1db2df0d4304 100644 --- a/spec/support/menu_helper.rb +++ b/spec/support/menu_helper.rb @@ -36,6 +36,27 @@ def section_file def item_file create_temp_file(ITEM_DEF) end + + def settings_custom_items + [ + { + :type => 'item', + :icon => 'fa fa-bug', + :id => 'custom_i1', + :name => 'Custom Item 1', + :href => 'https://www.redhat.com', + :rbac => 'vm_explorer' + }, + { + :type => 'item', + :icon => 'pficon pficon-help', + :id => 'custom_i2', + :name => 'Custom Item 2', + :href => 'https://www.hmpf.cz', + :rbac => 'vm_explorer' + } + ] + end end end end