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

Initial spec for Meetings::RowComponent

Alexander Brandon Coles851c1b6a5b0d
diff --git a/modules/meeting/spec/components/meetings/row_component_spec.rb b/modules/meeting/spec/components/meetings/row_component_spec.rb
new file mode 100644
index 00000000000..ead083d0fbe
--- /dev/null
+++ b/modules/meeting/spec/components/meetings/row_component_spec.rb
@@ -0,0 +1,111 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 "rails_helper"
+
+RSpec.describe Meetings::RowComponent, type: :component do
+ include Rails.application.routes.url_helpers
+
+ let(:table) { instance_double(Meetings::TableComponent, columns: [], grid_class: "test", has_actions?: true) }
+ let(:project) { build_stubbed(:project) }
+ let(:user) { build_stubbed(:user) }
+
+ subject do
+ render_inline(described_class.new(row: meeting, table:))
+ page
+ end
+
+ before do
+ login_as(user)
+ end
+
+ describe "actions" do
+ context "with default permissions" do
+ context "with a one-off meeting" do
+ let(:meeting) { build_stubbed(:meeting, project:) }
+
+ it "shows default menu items" do
+ expect(subject).to have_link "Download iCalendar event"
+ end
+ end
+
+ context "with an associated recurring/templated meeting" do
+ let(:series) { build_stubbed(:recurring_meeting, project:) }
+ let(:meeting) { build_stubbed(:structured_meeting_template, recurring_meeting: series, project:) }
+
+ it "shows default menu items" do
+ expect(subject).to have_link "View meeting series"
+ expect(subject).to have_link "Download iCalendar event"
+ end
+ end
+ end
+
+ context "with project delete meetings permissions" do
+ before do
+ mock_permissions_for(user) do |mock|
+ mock.allow_in_project(:delete_meetings, project:)
+ end
+ end
+
+ context "with a one-off meeting" do
+ let(:meeting) { build_stubbed(:meeting, project:) }
+
+ it "shows delete menu item" do
+ expect(subject).to have_link "Delete meeting", href: delete_dialog_meeting_path(meeting)
+ end
+ end
+
+ context "with an associated recurring/templated meeting" do
+ let(:series) { build_stubbed(:recurring_meeting, project:) }
+ let(:meeting) { build_stubbed(:structured_meeting_template, recurring_meeting: series, project:) }
+
+ it "shows delete menu item" do
+ expect(subject).to have_link "Delete occurrence", href: delete_dialog_meeting_path(meeting)
+ end
+ end
+ end
+
+ context "with project create meetings permissions" do
+ before do
+ mock_permissions_for(user) do |mock|
+ mock.allow_in_project(:create_meetings, project:)
+ end
+ end
+
+ context "with a one-off meeting" do
+ let(:meeting) { build_stubbed(:meeting, project:) }
+
+ it "shows copy menu item" do
+ expect(subject).to have_link "Copy meeting"
+ end
+ end
+ end
+ end
+end