Merge pull request #7718 from opf/fix/hide_menu_items_from_overview_too

hide menu items both from side menu and overview panel
pull/7720/head
Markus Kahl 5 years ago committed by GitHub
commit 6f8c50e626
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/controllers/admin_controller.rb
  2. 41
      spec/controllers/admin_controller_spec.rb

@ -38,8 +38,8 @@ class AdminController < ApplicationController
def index def index
@menu_nodes = Redmine::MenuManager.items(:admin_menu).children @menu_nodes = Redmine::MenuManager.items(:admin_menu).children
@menu_nodes.delete_if { |node| node.name === :enterprise } unless OpenProject::Configuration.ee_manager_visible?
@menu_nodes.delete_if { |node| node.name === :admin_overview } @menu_nodes.delete_if { |node| node.name === :admin_overview }
@menu_nodes.delete_if { |node| node.condition && !node.condition.call }
end end
def projects def projects

@ -42,6 +42,47 @@ describe AdminController, type: :controller do
expect(response).to be_successful expect(response).to be_successful
expect(response).to render_template 'index' expect(response).to render_template 'index'
end end
describe "with a plugin adding a menu item" do
render_views
let(:visible) { true }
let(:plugin_name) { nil }
before do
show = visible
name = plugin_name
Redmine::Plugin.register name.to_sym do
menu :admin_menu,
:"#{name}_settings",
{ controller: '/settings', action: :plugin, id: :"openproject_#{name}" },
caption: name.capitalize,
icon: 'icon2 icon-arrow',
if: ->(*) { show }
end
get :index
end
context "with the menu item visible" do
let(:plugin_name) { "Apple" }
let(:visible) { true }
it "should show the plugin in the overview" do
expect(response.body).to have_selector('a.menu-block', text: plugin_name.capitalize)
end
end
context "with the menu item hidden" do
let(:plugin_name) { "Orange" }
let(:visible) { false }
it "should not show the plugin in the overview" do
expect(response.body).not_to have_selector('a.menu-block', text: plugin_name.capitalize)
end
end
end
end end
describe '#plugins' do describe '#plugins' do

Loading…
Cancel
Save