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 specs
Mir Bhatia72b117321c1d
diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.html.erbindex 5e1e69e9e94..9aeb8f7fb32 100644--- a/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.html.erb+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.html.erb@@ -9,7 +9,7 @@grid.with_area(:notes,display: display_notes_input_value,- data: { "meeting-agenda-item-form-target": "notesInput" }+ data: { "test-selector": "meeting-outcome-input" }) dorender(MeetingAgendaItem::Outcome::Notes.new(f))enddiff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.html.erbindex 355e7aa2c66..c0e683eeb01 100644--- a/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.html.erb+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.html.erb@@ -22,7 +22,7 @@ml: 2,test_selector: "op-meeting-outcome-actions")- edit_action_item(menu) if @meeting_outcome.editable?+ edit_action_item(menu)copy_action_item(menu)menu.with_dividerdelete_action_item(menu)diff --git a/modules/meeting/app/contracts/meeting_outcomes/editable_item.rb b/modules/meeting/app/contracts/meeting_outcomes/editable_item.rbindex abca63397dd..c41c0c390ef 100644--- a/modules/meeting/app/contracts/meeting_outcomes/editable_item.rb+++ b/modules/meeting/app/contracts/meeting_outcomes/editable_item.rb@@ -39,6 +39,8 @@ module MeetingOutcomesprotecteddef validate_editable+ return unless visible?+unless model.editable?errors.add :base, I18n.t(:text_outcome_not_editable_anymore)end@@ -53,6 +55,8 @@ module MeetingOutcomesenddef user_allowed_to_add+ return unless visible?+unless user.allowed_in_project?(:create_meeting_minutes, model.meeting_agenda_item.project)errors.add :base, :error_unauthorizedenddiff --git a/modules/meeting/spec/contracts/meeting_outcomes/create_contract_spec.rb b/modules/meeting/spec/contracts/meeting_outcomes/create_contract_spec.rbnew file mode 100644index 00000000000..c85321449e9--- /dev/null+++ b/modules/meeting/spec/contracts/meeting_outcomes/create_contract_spec.rb@@ -0,0 +1,90 @@+# 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 "spec_helper"+require "contracts/shared/model_contract_shared_context"++RSpec.describe MeetingOutcomes::CreateContract do+ include_context "ModelContract shared context"++ shared_let(:project) { create(:project) }+ let(:meeting) { create(:structured_meeting, project:) }+ let(:meeting_agenda_item) { create(:meeting_agenda_item, meeting:) }+ let(:outcome) { build(:meeting_outcome, meeting_agenda_item:) }+ let(:contract) { described_class.new(outcome, user) }++ context "with permission" do+ let(:user) do+ create(:user, member_with_permissions: { project => %i[view_meetings create_meeting_minutes] })+ end++ context "when :meeting is 'in_progress'" do+ before do+ meeting.update_column(:state, :in_progress)+ end++ it_behaves_like "contract is valid"+ end++ context "when :meeting is 'open'" do+ before do+ meeting.update_column(:state, :open)+ end++ it_behaves_like "contract is invalid", base: I18n.t(:text_outcome_not_editable_anymore)+ end++ context "when :meeting is 'closed'" do+ before do+ meeting.update_column(:state, :closed)+ end++ it_behaves_like "contract is invalid", base: I18n.t(:text_outcome_not_editable_anymore)+ end++ context "when :meeting_agenda_item is not present anymore" do+ before do+ meeting_agenda_item.destroy+ end++ it_behaves_like "contract is invalid", base: I18n.t(:text_outcome_not_editable_anymore)+ end+ end++ context "without permission" do+ let(:user) { build_stubbed(:user) }++ it_behaves_like "contract is invalid", base: :does_not_exist+ end++ include_examples "contract reuses the model errors" do+ let(:user) { build_stubbed(:user) }+ end+enddiff --git a/modules/meeting/spec/contracts/meeting_outcomes/delete_contract_spec.rb b/modules/meeting/spec/contracts/meeting_outcomes/delete_contract_spec.rbnew file mode 100644index 00000000000..999ce1800de--- /dev/null+++ b/modules/meeting/spec/contracts/meeting_outcomes/delete_contract_spec.rb@@ -0,0 +1,82 @@+# 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 "spec_helper"+require "contracts/shared/model_contract_shared_context"++RSpec.describe MeetingOutcomes::DeleteContract do+ include_context "ModelContract shared context"++ shared_let(:project) { create(:project) }+ shared_let(:meeting) { create(:structured_meeting, project:) }+ let(:meeting_agenda_item) { create(:meeting_agenda_item, meeting:) }+ let(:outcome) { build_stubbed(:meeting_outcome, meeting_agenda_item:) }+ let(:contract) { described_class.new(outcome, user) }++ context "with permission" do+ let(:user) do+ create(:user, member_with_permissions: { project => %i[view_meetings create_meeting_minutes] })+ end++ context "when :meeting is 'in_progress'" do+ before do+ meeting.update_column(:state, :in_progress)+ end++ it_behaves_like "contract is valid"+ end++ context "when :meeting is 'open'" do+ before do+ meeting.update_column(:state, :open)+ end++ it_behaves_like "contract is invalid", base: I18n.t(:text_outcome_not_editable_anymore)+ end++ context "when :meeting is 'closed'" do+ before do+ meeting.update_column(:state, :closed)+ end++ it_behaves_like "contract is invalid", base: I18n.t(:text_outcome_not_editable_anymore)+ end+ end++ context "without permission" do+ let(:user) { build_stubbed(:user) }++ it_behaves_like "contract is invalid", base: %i[error_unauthorized does_not_exist]+ end++ include_examples "contract reuses the model errors" do+ let(:user) { build_stubbed(:user) }+ end+enddiff --git a/modules/meeting/spec/contracts/meeting_outcomes/update_contract_spec.rb b/modules/meeting/spec/contracts/meeting_outcomes/update_contract_spec.rbnew file mode 100644index 00000000000..0b6fd928cc8--- /dev/null+++ b/modules/meeting/spec/contracts/meeting_outcomes/update_contract_spec.rb@@ -0,0 +1,90 @@+# 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 "spec_helper"+require "contracts/shared/model_contract_shared_context"++RSpec.describe MeetingOutcomes::UpdateContract do+ include_context "ModelContract shared context"++ shared_let(:project) { create(:project) }+ let(:meeting) { create(:structured_meeting, project:) }+ let(:meeting_agenda_item) { create(:meeting_agenda_item, meeting:) }+ let(:outcome) { build(:meeting_outcome, meeting_agenda_item:) }+ let(:contract) { described_class.new(outcome, user) }++ context "with permission" do+ let(:user) do+ create(:user, member_with_permissions: { project => %i[view_meetings create_meeting_minutes] })+ end++ context "when :meeting is 'in_progress'" do+ before do+ meeting.update_column(:state, :in_progress)+ end++ it_behaves_like "contract is valid"+ end++ context "when :meeting is 'open'" do+ before do+ meeting.update_column(:state, :open)+ end++ it_behaves_like "contract is invalid", base: I18n.t(:text_outcome_not_editable_anymore)+ end++ context "when :meeting is 'closed'" do+ before do+ meeting.update_column(:state, :closed)+ end++ it_behaves_like "contract is invalid", base: I18n.t(:text_outcome_not_editable_anymore)+ end++ context "when :meeting_agenda_item is not present anymore" do+ before do+ meeting_agenda_item.destroy+ end++ it_behaves_like "contract is invalid", base: I18n.t(:text_outcome_not_editable_anymore)+ end+ end++ context "without permission" do+ let(:user) { build_stubbed(:user) }++ it_behaves_like "contract is invalid", base: :does_not_exist+ end++ include_examples "contract reuses the model errors" do+ let(:user) { build_stubbed(:user) }+ end+enddiff --git a/modules/meeting/spec/factories/meeting_outcome_factory.rb b/modules/meeting/spec/factories/meeting_outcome_factory.rbnew file mode 100644index 00000000000..ca8f55a5920--- /dev/null+++ b/modules/meeting/spec/factories/meeting_outcome_factory.rb@@ -0,0 +1,37 @@+# 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.+#++++FactoryBot.define do+ factory :meeting_outcome do |m|+ meeting_agenda_item factory: :meeting_agenda_item+ kind { :information }+ m.sequence(:notes) { |n| "Meeting outcome #{n}" }+ end+enddiff --git a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rbindex c56c2a9b476..09e711c2cff 100644--- a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb+++ b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb@@ -1,4 +1,5 @@# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbHdiff --git a/modules/meeting/spec/features/structured_meetings/meeting_outcomes/meeting_outcomes_crud_spec.rb b/modules/meeting/spec/features/structured_meetings/meeting_outcomes/meeting_outcomes_crud_spec.rbnew file mode 100644index 00000000000..4f7c266cf94--- /dev/null+++ b/modules/meeting/spec/features/structured_meetings/meeting_outcomes/meeting_outcomes_crud_spec.rb@@ -0,0 +1,170 @@+# 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 "spec_helper"++require_relative "../../../support/pages/structured_meeting/show"++RSpec.describe "Meeting Outcomes CRUD",+ :js,+ with_flag: { meeting_outcomes: true } do+ shared_let(:project) { create(:project, enabled_module_names: %w[meetings]) }+ shared_let(:user) do+ create :user,+ lastname: "First",+ preferences: { time_zone: "Etc/UTC" },+ member_with_permissions: { project => %i[view_meetings manage_agendas close_meeting_agendas create_meeting_minutes] }+ end+ shared_let(:other_user) do+ create :user,+ lastname: "Second",+ member_with_permissions: { project => %i[view_meetings manage_agendas close_meeting_agendas] }+ end+ shared_let(:meeting) do+ create :structured_meeting,+ project:,+ start_time: "2024-12-31T13:30:00Z",+ duration: 1.5,+ author: user+ end++ shared_let(:meeting_agenda_item) { create(:meeting_agenda_item, meeting:) }+ shared_let(:work_package) { create(:work_package, project:) }+ shared_let(:wp_agenda_item) { create(:wp_meeting_agenda_item, meeting:, work_package:) }++ let(:current_user) { user }+ let(:state) { :in_progress }+ let(:show_page) { Pages::StructuredMeeting::Show.new(meeting) }+ let(:field) do+ TextEditorField.new(page, "Outcome", selector: test_selector("meeting-outcome-input"))+ end++ context "when a user has the necessary 'create_meeting_minutes' permission" do+ before do+ meeting.update(state: state)+ login_as current_user+ end++ context "when the meeting is 'in progress'" do+ it "can view outcomes and do all actions" do+ item = MeetingAgendaItem.find(meeting_agenda_item.id)++ show_page.visit!++ show_page.add_outcome_from_menu(item) do+ field.expect_active!+ field.set_value "Hakuna Matata"+ click_link_or_button "Save"+ end++ show_page.in_outcome_component(item) do+ show_page.expect_outcome "Hakuna Matata"++ show_page.select_outcome_action "Remove outcome"++ show_page.expect_no_outcome "Hakuna Matata"+ expect(page).to have_css(".op-meeting-outcome--button")+ end++ wp_item = MeetingAgendaItem.find(wp_agenda_item.id)++ show_page.add_outcome(wp_item) do+ field.expect_active!+ field.set_value "It means no worries"+ click_link_or_button "Save"+ end++ show_page.in_outcome_component(wp_item) do+ show_page.expect_outcome "It means no worries"++ show_page.select_outcome_action "Edit outcome"+ field.expect_active!+ field.set_value "Updated outcome"+ click_link_or_button "Save"++ show_page.expect_outcome "Updated outcome"+ end++ show_page.expect_no_outcome_action(wp_item)+ end+ end++ context "when the meeting is 'open'" do+ let!(:state) { :open }+ let(:outcome) { create(:meeting_outcome, meeting_agenda_item:, notes: "Existing outcome") }++ before do+ outcome+ show_page.visit!+ end++ it "can only view existing outcomes" do+ show_page.expect_outcome "Existing outcome"+ show_page.expect_no_outcome_actions+ show_page.expect_no_outcome_button++ item = MeetingAgendaItem.find(meeting_agenda_item.id)+ wp_item = MeetingAgendaItem.find(wp_agenda_item.id)++ show_page.expect_no_outcome_action(item)+ show_page.expect_no_outcome_action(wp_item)+ end+ end++ context "when the meeting is 'closed'" do+ let!(:state) { :closed }+ let(:outcome) { create(:meeting_outcome, meeting_agenda_item:, notes: "Existing outcome") }++ before do+ outcome+ show_page.visit!+ end++ it "can only view existing outcomes" do+ show_page.expect_outcome "Existing outcome"+ show_page.expect_no_outcome_actions+ show_page.expect_no_outcome_button+ end+ end+ end++ context "when a user doesn't have the necessary permission" do+ let(:outcome) { create(:meeting_outcome, meeting_agenda_item:, notes: "Existing outcome") }++ before do+ outcome+ meeting.update(state: state)+ login_as other_user+ show_page.visit!+ end++ it "can only view existing outcomes" do+ show_page.expect_outcome "Existing outcome"+ show_page.expect_no_outcome_actions+ show_page.expect_no_outcome_button+ end+ end+enddiff --git a/modules/meeting/spec/support/pages/structured_meeting/show.rb b/modules/meeting/spec/support/pages/structured_meeting/show.rbindex e633a46bb5a..6cc8186dcfa 100644--- a/modules/meeting/spec/support/pages/structured_meeting/show.rb+++ b/modules/meeting/spec/support/pages/structured_meeting/show.rb@@ -159,6 +159,34 @@ module Pages::StructuredMeetingendend+ def select_outcome_action(action)+ retry_block do+ page.find_test_selector("op-meeting-outcome-actions").click+ page.find(".Overlay")+ end++ page.within(".Overlay") do+ click_on action+ end+ end++ def expect_no_outcome_actions+ expect(page).to have_no_css("op-meeting-outcome-actions")+ end++ def expect_no_outcome_action(item)+ retry_block do+ page.within("#meeting-agenda-items-item-component-#{item.id}") do+ page.find_test_selector("op-meeting-agenda-actions").trigger("click")+ end+ page.find(".Overlay")+ end++ page.within(".Overlay") do+ expect(page).to have_no_text("Add outcome")+ end+ end+def select_section_action(section, action)retry_block doclick_on_section_menu(section)@@ -176,6 +204,44 @@ module Pages::StructuredMeetingendend+ def in_outcome_component(item, &)+ page.within("#meeting-agenda-items-outcomes-base-component-#{item.id}", &)+ end++ def add_outcome(item, &)+ page.within("#meeting-agenda-items-outcomes-base-component-#{item.id}") do+ click_link_or_button "Outcome"+ page.within(".ActionListItem") do+ click_link_or_button "Outcome"+ end+ end+ expect_outcome_form(item)+ page.within("#meeting-agenda-items-outcomes-input-component-#{item.id}", &)+ end++ def add_outcome_from_menu(item, &)+ select_action item, "Add outcome"+ expect_outcome_form(item)+ page.within("#meeting-agenda-items-outcomes-input-component-#{item.id}", &)+ end++ def expect_outcome_form(item)+ expect(page)+ .to have_css("#meeting-agenda-items-outcomes-input-component-#{item.id}")+ end++ def expect_outcome(text)+ expect(page).to have_css("#meeting-agenda-items-outcomes-show-notes-component", text:)+ end++ def expect_no_outcome(text)+ expect(page).to have_no_css("#meeting-agenda-items-outcomes-show-notes-component", text:)+ end++ def expect_no_outcome_button+ expect(page).to have_no_css("op-meeting-outcome--button")+ end+def edit_agenda_item(item, &)select_action item, "Edit"expect_item_edit_form(item)