OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add the `News` menu item to the global menu
Aaron Contreras744411d6ac5b
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rbindex e899e094e9e..748dab48613 100644--- a/app/controllers/news_controller.rb+++ b/app/controllers/news_controller.rb@@ -48,7 +48,7 @@ class NewsController < ApplicationControllerrespond_to do |format|format.html do- render layout: layout_non_or_no_menu+ render locals: { menu_name: project_or_global_menu }endformat.atom dorender_feed(@newss,diff --git a/config/initializers/menus.rb b/config/initializers/menus.rbindex 74a4202a0a5..a4ffe77bd2b 100644--- a/config/initializers/menus.rb+++ b/config/initializers/menus.rb@@ -149,6 +149,17 @@ Redmine::MenuManager.map :global_menu do |menu|{ controller: '/work_packages', action: 'index' },parent: :work_packages,partial: 'work_packages/menu_query_select'++ # News+ menu.push :news,+ { controller: '/news', project_id: nil, action: 'index' },+ caption: I18n.t('label_news_plural'),+ icon: 'news',+ after: :boards,+ if: Proc.new {+ (User.current.logged? || !Setting.login_required?) &&+ User.current.allowed_to_globally?(:view_news)+ }endRedmine::MenuManager.map :global_work_packages_menu do |menu|diff --git a/modules/boards/lib/open_project/boards/engine.rb b/modules/boards/lib/open_project/boards/engine.rbindex 96d48d28a76..612e94d8696 100644--- a/modules/boards/lib/open_project/boards/engine.rb+++ b/modules/boards/lib/open_project/boards/engine.rb@@ -71,6 +71,7 @@ module OpenProject::Boards:boards,{ controller: '/boards/boards', action: 'overview' },caption: :project_module_board_view,+ before: :news,after: :team_planners,icon: 'boards',if: should_render_global_menu_itemdiff --git a/spec/features/news/creation_and_commenting_spec.rb b/spec/features/news/creation_and_commenting_spec.rbindex b2555174e89..5ca5c83c59c 100644--- a/spec/features/news/creation_and_commenting_spec.rb+++ b/spec/features/news/creation_and_commenting_spec.rb@@ -28,7 +28,7 @@require 'spec_helper'-RSpec.describe 'News creation and commenting', js: true do+RSpec.describe 'News creation and commenting', :js, :with_cuprite dolet(:project) { create(:project) }let!(:other_user) docreate(:user,diff --git a/spec/features/news/global_menu_item_spec.rb b/spec/features/news/global_menu_item_spec.rbnew file mode 100644index 00000000000..3c7506069a1--- /dev/null+++ b/spec/features/news/global_menu_item_spec.rb@@ -0,0 +1,68 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# +++#++require 'spec_helper'++RSpec.describe 'News global menu item spec', :js, :with_cuprite do+ shared_let(:admin) { create(:admin) }+ shared_let(:user_without_permissions) { create(:user) }++ before do+ login_as current_user+ visit root_path+ end++ context 'as a user with permissions' do+ let(:current_user) { admin }++ it 'navigates to the global news page' do+ within '#main-menu' do+ click_link 'News'+ end++ expect(page).to have_current_path(news_index_path)++ within '#main-menu' do+ expect(page).to have_selector('.selected', text: 'News')+ end+ end+ end++ context 'as a user without permissions' do+ let(:current_user) { user_without_permissions }++ it "doesn't render the menu item" do+ within '#main-menu' do+ expect(page).not_to have_link 'News'+ end+ end+ end+enddiff --git a/spec/lib/redmine/menu_manager_spec.rb b/spec/lib/redmine/menu_manager_spec.rbindex 422e69a9ff6..ef08f1cbe86 100644--- a/spec/lib/redmine/menu_manager_spec.rb+++ b/spec/lib/redmine/menu_manager_spec.rb@@ -52,7 +52,14 @@ RSpec.describe Redmine::MenuManager docontext 'for the global_menu' doit 'includes the expected items' doexpect(described_class.items(:global_menu).map(&:name))- .to include(:home, :activity, :work_packages, :calendar_view, :team_planners, :boards, :cost_reports_global)+ .to include(:home,+ :activity,+ :work_packages,+ :calendar_view,+ :team_planners,+ :boards,+ :news,+ :cost_reports_global)endend