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

Fix destroy of meetings with attachments

Oliver Günthera1bf5e3a980b
diff --git a/modules/meeting/app/models/meeting/virtual_start_time.rb b/modules/meeting/app/models/meeting/virtual_start_time.rb
index b64f388277b..947f6d19c35 100644
--- a/modules/meeting/app/models/meeting/virtual_start_time.rb
+++ b/modules/meeting/app/models/meeting/virtual_start_time.rb
@@ -129,6 +129,8 @@ module Meeting::VirtualStartTime
##
# Enforce HH::MM time parsing for the given input string
def parsed_start_time_hour
+ return nil if @start_time_hour.nil?
+
Time.strptime(@start_time_hour, "%H:%M")
rescue ArgumentError
nil
diff --git a/modules/meeting/spec/models/meeting_spec.rb b/modules/meeting/spec/models/meeting_spec.rb
index 4f1a513957b..bb768829196 100644
--- a/modules/meeting/spec/models/meeting_spec.rb
+++ b/modules/meeting/spec/models/meeting_spec.rb
@@ -230,4 +230,16 @@ RSpec.describe Meeting do
expect(meeting.formatted_duration).to be_nil
end
end
+
+ describe "#destroy" do
+ context "with an attachment" do
+ let!(:meeting) { create(:meeting, project: project) }
+ let!(:attachment) { create(:attachment, container: meeting) }
+
+ it "does not raise an exception (Regression #61632)" do
+ expect { meeting.destroy! }.not_to raise_error
+ expect { meeting.reload }.to raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
+ end
end