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
[#50817] Meetings: adding work package item without selecting a work package results in an error
Dombi Attila6a2c015b8899
diff --git a/modules/meeting/app/models/meeting_agenda_item.rb b/modules/meeting/app/models/meeting_agenda_item.rbindex 348b69067cf..665afd2728d 100644--- a/modules/meeting/app/models/meeting_agenda_item.rb+++ b/modules/meeting/app/models/meeting_agenda_item.rb@@ -70,7 +70,7 @@ class MeetingAgendaItem < ApplicationRecordenddef deleted_work_package?- item_type == "work_package" && work_package_id.nil?+ persisted? && item_type == "work_package" && work_package_id.nil?enddef editable?diff --git a/modules/meeting/spec/models/meeting_agenda_item_spec.rb b/modules/meeting/spec/models/meeting_agenda_item_spec.rbindex db022b8926d..2eef69aecc1 100644--- a/modules/meeting/spec/models/meeting_agenda_item_spec.rb+++ b/modules/meeting/spec/models/meeting_agenda_item_spec.rb@@ -31,8 +31,9 @@ require_relative "../spec_helper"RSpec.describe MeetingAgendaItem dolet(:meeting) { build_stubbed(:structured_meeting) }let(:attributes) { {} }+ let(:meeting_agenda_item) { described_class.new(meeting:, **attributes) }- subject { described_class.new(meeting:, **attributes) }+ subject { meeting_agenda_item }describe '#author' dolet(:attributes) { { title: 'foo', author: } }@@ -207,4 +208,59 @@ RSpec.describe MeetingAgendaItem doendendend++ describe '#deleted_work_package?' do+ subject { meeting_agenda_item.deleted_work_package? }++ let(:attributes) { { work_package_id:, item_type: } }++ context 'when item_type is not "work_package"' do+ let(:item_type) { :simple }+ let(:work_package_id) { nil }++ context 'and the agenda_item is not persisted' do+ it { is_expected.to be false }+ end++ context 'and the agenda_item is persisted' do+ let(:meeting_agenda_item) { build_stubbed(:meeting_agenda_item, meeting:, **attributes) }++ it { is_expected.to be false }+ end+ end++ context 'when item_type is "work_package"' do+ let(:item_type) { :work_package }++ context 'and the agenda_item is not persisted' do+ context 'and work_package_id is missing' do+ let(:work_package_id) { nil }++ it { is_expected.to be false }+ end++ context 'and work_package_id is present' do+ let(:work_package_id) { 1 }++ it { is_expected.to be false }+ end+ end++ context 'and the agenda_item is persisted' do+ let(:meeting_agenda_item) { build_stubbed(:meeting_agenda_item, meeting:, **attributes) }++ context 'and work_package_id is missing' do+ let(:work_package_id) { nil }++ it { is_expected.to be true }+ end++ context 'and work_package_id is present' do+ let(:work_package_id) { 1 }++ it { is_expected.to be false }+ end+ end+ end+ endend