Skip to content

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

Implement tests

Klaus Zanders09c4be26c9b9
diff --git a/modules/boards/app/controllers/boards/boards_controller.rb b/modules/boards/app/controllers/boards/boards_controller.rb
index 3193b26430d..c316e382b58 100644
--- a/modules/boards/app/controllers/boards/boards_controller.rb
+++ b/modules/boards/app/controllers/boards/boards_controller.rb
@@ -18,7 +18,7 @@ module ::Boards
end
def overview
- projects = Project.allowed_to(User.current, :view_meetings)
+ projects = Project.allowed_to(User.current, :view_boards)
@board_grids = Boards::Grid.includes(:project).where(project: projects)
end
diff --git a/modules/boards/lib/open_project/boards/engine.rb b/modules/boards/lib/open_project/boards/engine.rb
index 6de54e0629a..216ec423cbf 100644
--- a/modules/boards/lib/open_project/boards/engine.rb
+++ b/modules/boards/lib/open_project/boards/engine.rb
@@ -29,7 +29,7 @@ module OpenProject::Boards
name: 'OpenProject Boards' do
project_module :board_view, dependencies: :work_package_tracking, order: 80 do
permission :show_board_views,
- { 'boards/boards': %i[index] },
+ { 'boards/boards': %i[index overview] },
dependencies: :view_work_packages,
contract_actions: { boards: %i[read] }
permission :manage_board_views,
diff --git a/modules/boards/spec/features/board_overview_spec.rb b/modules/boards/spec/features/board_overview_spec.rb
new file mode 100644
index 00000000000..f83934d4da8
--- /dev/null
+++ b/modules/boards/spec/features/board_overview_spec.rb
@@ -0,0 +1,101 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-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'
+require_relative './support/board_overview_page'
+
+describe 'Work Package boards overview spec', with_ee: %i[board_view], with_flag: { more_global_index_pages: true } do
+ let(:user) do
+ create(:user,
+ member_in_project: project,
+ member_through_role: role)
+ end
+ # The identifier is important to test https://community.openproject.com/wp/29754
+ let(:project) { create(:project, identifier: 'boards', enabled_module_names: %i[work_package_tracking board_view]) }
+ let(:other_project) { create(:project, enabled_module_names: %i[work_package_tracking board_view]) }
+ let(:permissions) { %i[show_board_views manage_board_views add_work_packages view_work_packages manage_public_queries] }
+ let(:role) { create(:role, permissions:) }
+ let!(:priority) { create(:default_priority) }
+ let!(:status) { create(:default_status) }
+ let(:board_overview) { Pages::BoardOverview.new }
+ let(:board_view) { create(:board_grid_with_query, name: 'My board', project:) }
+ let(:other_board_view) { create(:board_grid_with_query, name: 'My other board', project:) }
+ let(:other_project_board_view) { create(:board_grid_with_query, name: 'Unseeable Board', project: other_project) }
+
+ before do
+ login_as(user)
+ end
+
+ context 'when no boards exist' do
+ it 'displays the empty message' do
+ board_overview.visit!
+
+ board_overview.expect_no_boards_listed
+ end
+ end
+
+ context 'when only boards exist that the user does not have access to' do
+ before do
+ other_project_board_view
+ end
+
+ it 'displays the empty message' do
+ board_overview.visit!
+
+ board_overview.expect_no_boards_listed
+ end
+ end
+
+ context 'when boards exists' do
+ before do
+ board_view
+ other_board_view
+ other_project_board_view
+ end
+
+ it 'lists the boards' do
+ board_overview.visit!
+
+ board_overview.expect_boards_listed(board_view, other_board_view)
+ board_overview.expect_boards_not_listed(other_project_board_view)
+ end
+
+ it 'paginates results', with_settings: { per_page_options: '1' } do
+ # First page displays the historically last meeting
+ board_overview.visit!
+ board_overview.expect_boards_listed(board_view)
+ board_overview.expect_boards_not_listed(other_board_view)
+
+ board_overview.expect_to_be_on_page(1)
+
+ board_overview.to_page(2)
+ board_overview.expect_boards_listed(other_board_view)
+ board_overview.expect_boards_not_listed(board_view)
+ end
+ end
+end
diff --git a/modules/boards/spec/features/support/board_index_page.rb b/modules/boards/spec/features/support/board_index_page.rb
index 348afa0649b..bebbb9bf3b7 100644
--- a/modules/boards/spec/features/support/board_index_page.rb
+++ b/modules/boards/spec/features/support/board_index_page.rb
@@ -34,6 +34,8 @@ module Pages
attr_reader :project
def initialize(project = nil)
+ super()
+
@project = project
end
diff --git a/modules/boards/spec/features/support/board_overview_page.rb b/modules/boards/spec/features/support/board_overview_page.rb
new file mode 100644
index 00000000000..1fd2153cf8f
--- /dev/null
+++ b/modules/boards/spec/features/support/board_overview_page.rb
@@ -0,0 +1,70 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-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 'support/pages/page'
+require_relative './board_page'
+
+module Pages
+ class BoardOverview < Page
+ def visit!
+ navigate_to_modules_menu_item("Boards")
+ end
+
+ def expect_no_boards_listed
+ within '#content-wrapper' do
+ expect(page).to have_content I18n.t(:no_results_title_text)
+ end
+ end
+
+ def expect_boards_listed(*boards)
+ within '#content-wrapper' do
+ boards.each do |board|
+ expect(page).to have_selector("td.name", text: board.name)
+ end
+ end
+ end
+
+ def expect_to_be_on_page(number)
+ expect(page).to have_selector('.op-pagination--item_current', text: number)
+ end
+
+ def to_page(number)
+ within '.op-pagination--pages' do
+ click_link number.to_s
+ end
+ end
+
+ def expect_boards_not_listed(*boards)
+ within '#content-wrapper' do
+ boards.each do |board|
+ expect(page).not_to have_selector("td.title", text: board.name)
+ end
+ end
+ end
+ end
+end
diff --git a/modules/meeting/spec/support/pages/meetings/index.rb b/modules/meeting/spec/support/pages/meetings/index.rb
index 2a37400e58f..c6bdab8c390 100644
--- a/modules/meeting/spec/support/pages/meetings/index.rb
+++ b/modules/meeting/spec/support/pages/meetings/index.rb
@@ -99,11 +99,7 @@ module Pages::Meetings
end
def navigate_by_modules_menu
- visit root_path
-
- within '#more-menu', visible: false do
- click_on 'Meetings', visible: false
- end
+ navigate_to_modules_menu_item("Meetings")
end
def path
diff --git a/spec/support/pages/page.rb b/spec/support/pages/page.rb
index 962a4a2c232..c995103538a 100644
--- a/spec/support/pages/page.rb
+++ b/spec/support/pages/page.rb
@@ -176,5 +176,13 @@ module Pages
def toast_type
:angular
end
+
+ def navigate_to_modules_menu_item(link_title)
+ visit root_path
+
+ within '#more-menu', visible: false do
+ click_on link_title, visible: false
+ end
+ end
end
end