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
Show non-project queries on the global Gantt menu only
Henriette Darge034c19263ad6
diff --git a/modules/gantt/app/controllers/gantt/menus_controller.rb b/modules/gantt/app/controllers/gantt/menus_controller.rbindex fee1348062a..62a19a5d59a 100644--- a/modules/gantt/app/controllers/gantt/menus_controller.rb+++ b/modules/gantt/app/controllers/gantt/menus_controller.rb@@ -84,11 +84,14 @@ module Ganttdef base_querybase_query ||= Query.visible(current_user)- .joins(:views, :project)+ .includes(:project)+ .joins(:views).where('views.type' => 'gantt')if @project.present?base_query = base_query.where('queries.project_id' => @project.id)+ else+ base_query = base_query.where('queries.project_id' => nil)endbase_querydiff --git a/modules/gantt/spec/features/menu/global_gantt_menu_spec.rb b/modules/gantt/spec/features/menu/global_gantt_menu_spec.rbnew file mode 100644index 00000000000..bad2b9959e3--- /dev/null+++ b/modules/gantt/spec/features/menu/global_gantt_menu_spec.rb@@ -0,0 +1,112 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 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 'Gantt charts menu',+ :js,+ :selenium do+ let(:user) { create(:admin) }+ let(:enabled_module_names) { %i[work_package_tracking gantt] }+ let(:project) { create(:project, enabled_module_names:) }+ let(:wp_project_timeline) { Pages::WorkPackagesTimeline.new(project) }+ let(:wp_global_timeline) { Pages::WorkPackagesTimeline.new }++ let!(:global_private_query) do+ query = build(:global_query, user_id: user.id)+ query.timeline_visible = true+ query.public = false++ query.save!+ create(:view_gantt,+ query:)++ query+ end++ let!(:global_public_query) do+ query = build(:global_query, user_id: user.id)+ query.timeline_visible = true++ query.save!+ create(:view_gantt,+ query:)++ query+ end++ let!(:global_starred_query) do+ query = build(:global_query, user_id: user.id)+ query.timeline_visible = true+ query.starred = true++ query.save!+ create(:view_gantt,+ query:)++ query+ end++ let!(:private_project_query) do+ query = create(:query_with_view_gantt, user:, project:)+ query.timeline_visible = true++ query.save!+ query+ end++ before do+ login_as(user)+ end++ describe 'on the global Gantt charts page' do+ it 'shows all queries without a project' do+ wp_global_timeline.visit!+ loading_indicator_saveguard++ # Show global queries only+ expect(page).to have_css('.op-sidemenu--item-action', text: global_starred_query)+ expect(page).to have_css('.op-sidemenu--item-action', text: global_public_query)+ expect(page).to have_css('.op-sidemenu--item-action', text: global_private_query)+ expect(page).to have_no_css('.op-sidemenu--item-action', text: private_project_query)+ end+ end++ describe 'on the project Gantt charts page' do+ it 'shows all queries that belong to the project' do+ wp_project_timeline.visit!+ loading_indicator_saveguard++ # Show project queries only+ expect(page).to have_no_css('.op-sidemenu--item-action', text: global_starred_query)+ expect(page).to have_no_css('.op-sidemenu--item-action', text: global_public_query)+ expect(page).to have_no_css('.op-sidemenu--item-action', text: global_private_query)+ expect(page).to have_css('.op-sidemenu--item-action', text: private_project_query)+ end+ end+end