Skip to content

Commit

Permalink
Custom top-level menu items via settings: add specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpovolny committed May 31, 2019
1 parent aabad61 commit e5b75bb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/presenters/menu/menu_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions spec/presenters/menu/settings_loader_spec.rb
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions spec/support/menu_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e5b75bb

Please sign in to comment.