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

Add callback to unify which meetings agenda items belong to

Mir Bhatiae9de8f02d0c9
diff --git a/modules/meeting/app/models/meeting_agenda_item.rb b/modules/meeting/app/models/meeting_agenda_item.rb
index dacbd9b4062..5acc4906a46 100644
--- a/modules/meeting/app/models/meeting_agenda_item.rb
+++ b/modules/meeting/app/models/meeting_agenda_item.rb
@@ -72,6 +72,7 @@ class MeetingAgendaItem < ApplicationRecord
after_save :trigger_meeting_agenda_item_time_slots_calculation, if: Proc.new { |item|
item.duration_in_minutes_previously_changed? || item.position_previously_changed?
}
+ before_save :update_meeting_to_match_section
after_destroy :trigger_meeting_agenda_item_time_slots_calculation
# after_destroy :delete_meeting_section_if_empty
@@ -89,6 +90,13 @@ class MeetingAgendaItem < ApplicationRecord
end
end
+ def update_meeting_to_match_section
+ # TODO - see #63561
+ return if meeting == meeting_section.meeting
+
+ self.meeting = meeting_section.meeting
+ end
+
def trigger_meeting_agenda_item_time_slots_calculation
meeting.calculate_agenda_item_time_slots
end
diff --git a/modules/meeting/spec/models/meeting_acts_as_journalized_spec.rb b/modules/meeting/spec/models/meeting_acts_as_journalized_spec.rb
index 5d57eda6008..b502bace466 100644
--- a/modules/meeting/spec/models/meeting_acts_as_journalized_spec.rb
+++ b/modules/meeting/spec/models/meeting_acts_as_journalized_spec.rb
@@ -281,8 +281,10 @@ RSpec.describe Meeting do
end
describe "#destroy" do
+ let(:meeting_agenda_item) { create(:meeting_agenda_item, meeting:) }
+
before do
- meeting.agenda_items << create(:meeting_agenda_item)
+ meeting.agenda_items << meeting_agenda_item
meeting.save
end