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

Do not add multiple timezones when calling `to_ical` multiple times

Klaus Zanders6e9bfa90a3ba
diff --git a/modules/meeting/app/services/meetings/icalendar_builder.rb b/modules/meeting/app/services/meetings/icalendar_builder.rb
index 7cb2a4d6bbd..0cd59c5f6c9 100644
--- a/modules/meeting/app/services/meetings/icalendar_builder.rb
+++ b/modules/meeting/app/services/meetings/icalendar_builder.rb
@@ -158,6 +158,7 @@ module Meetings
end
def to_ical
+ calendar.timezones.clear
calendar.add_timezone(build_single_vtimezone)
calendar.to_ical
end
diff --git a/modules/meeting/spec/services/meetings/icalendar_builder_spec.rb b/modules/meeting/spec/services/meetings/icalendar_builder_spec.rb
index 8e251a736ad..20c1ddf35db 100644
--- a/modules/meeting/spec/services/meetings/icalendar_builder_spec.rb
+++ b/modules/meeting/spec/services/meetings/icalendar_builder_spec.rb
@@ -392,5 +392,12 @@ RSpec.describe Meetings::IcalendarBuilder,
expect(standard_count).to eq(4)
expect(daylight_count).to eq(4)
end
+
+ it "does not add the timezone multiple times when `to_ical` is called multiple times" do
+ meetings.each { |m| builder.add_single_meeting_event(meeting: m) }
+ builder.to_ical
+ builder.to_ical
+ expect(parsed_calendar.timezones.size).to eq(1)
+ end
end
end