Skip to content

Commit 6f9b4b7

Browse files
committed
Fix generation logic
1 parent b047ac8 commit 6f9b4b7

File tree

7 files changed

+32
-26
lines changed

7 files changed

+32
-26
lines changed

modules/meeting/app/services/meetings/icalendar_builder.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,19 @@ def build_single_vtimezone # rubocop:disable Metrics/AbcSize
199199
tz = Icalendar::Timezone.new
200200
tz.tzid = tzid
201201

202-
transitions = timezone.tzinfo.transitions_up_to(all_times.max, all_times.min)
203-
transitions.each do |tr|
204-
comp = tr.offset.dst? ? Icalendar::Timezone::Daylight.new : Icalendar::Timezone::Standard.new
205-
comp.dtstart = tr.at.utc.strftime("%Y%m%dT%H%M%SZ")
206-
comp.tzoffsetfrom = format_ical_offset(tr.previous_offset.utc_total_offset)
207-
comp.tzoffsetto = format_ical_offset(tr.offset.utc_total_offset)
208-
comp.tzname = tr.offset.abbreviation.to_s
209-
tz.add_component(comp)
202+
# We are investigating how to properly build this ... for now let's
203+
# just include everything from min - 6 months to max + 6 months
204+
if all_times.present?
205+
transitions = timezone.tzinfo.transitions_up_to(all_times.max + 6.months, all_times.min - 6.months)
206+
207+
transitions.each do |tr|
208+
comp = tr.offset.dst? ? Icalendar::Timezone::Daylight.new : Icalendar::Timezone::Standard.new
209+
comp.dtstart = tr.at.utc.strftime("%Y%m%dT%H%M%SZ")
210+
comp.tzoffsetfrom = format_ical_offset(tr.previous_offset.utc_total_offset)
211+
comp.tzoffsetto = format_ical_offset(tr.offset.utc_total_offset)
212+
comp.tzname = tr.offset.abbreviation.to_s
213+
tz.add_component(comp)
214+
end
210215
end
211216

212217
tz

modules/meeting/spec/mailers/meeting_mailer_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@
255255

256256
expect(entry.dtstart.utc).to eq meeting.start_time
257257
expect(entry.dtend.utc).to eq meeting.start_time + 1.hour
258-
expect(entry.summary).to eq "[My project] Important meeting"
259-
expect(entry.description).to eq "[My project] Meeting: Important meeting"
258+
expect(entry.summary).to eq "Important meeting"
259+
expect(entry.description).to eq "Important meeting"
260260
expect(entry.location).to eq(meeting.location.presence)
261261
end
262262

modules/meeting/spec/mailers/meeting_series_mailer_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
let(:i18n) do
5151
Class.new do
5252
include Redmine::I18n
53+
5354
public :format_date, :format_time
5455
end
5556
end
@@ -136,8 +137,8 @@
136137
expect(parsed).to be_a Array
137138
expect(parsed.length).to eq 1
138139

139-
expect(entry.summary).to eq "[My project] Recurring Standup"
140-
expect(entry.description).to eq "[My project] Meeting series: Recurring Standup"
140+
expect(entry.summary).to eq "Recurring Standup"
141+
expect(entry.description).to eq "Recurring Standup"
141142
expect(entry.location).to eq(series.template&.location.presence)
142143
end
143144
end

modules/meeting/spec/services/all_meetings/ical_service_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@
133133
expect(entry.attendee.map(&:to_s)).to match_array([user, user2].map { |u| "mailto:#{u.mail}" })
134134
expect(entry.dtstart.utc).to eq meeting.start_time
135135
expect(entry.dtend.utc).to eq meeting.start_time + 1.hour
136-
expect(entry.summary).to eq "[My Project] Important meeting"
137-
expect(entry.description).to eq "[My Project] Meeting: Important meeting"
136+
expect(entry.summary).to eq "Important meeting"
137+
expect(entry.description).to eq "Important meeting"
138138
expect(entry.location).to eq(meeting.location.presence)
139139
expect(entry.dtstart).to eq (relevant_time + 1.week).in_time_zone("Europe/Berlin")
140140
expect(entry.dtend).to eq (relevant_time + 1.week + 1.hour).in_time_zone("Europe/Berlin")
@@ -183,8 +183,8 @@
183183
expect(entry.uid).to eq(recurring_meeting.uid)
184184
expect(entry.organizer.to_s).to eq("mailto:#{Setting.mail_from}")
185185
expect(entry.attendee.map(&:to_s)).to match_array([user, user2].map { |u| "mailto:#{u.mail}" })
186-
expect(entry.summary).to eq "[My Project] Recurring meeting"
187-
expect(entry.description).to eq "[My Project] Meeting series: Recurring meeting"
186+
expect(entry.summary).to eq "Recurring meeting"
187+
expect(entry.description).to eq "Recurring meeting"
188188
expect(entry.location).to eq(recurring_meeting.template.location.presence)
189189

190190
expect(entry.exdate).to be_empty
@@ -225,8 +225,8 @@
225225
expect(entry.recurrence_id).to eq(meeting.scheduled_meeting.start_time)
226226
expect(entry.organizer.to_s).to eq("mailto:#{Setting.mail_from}")
227227
expect(entry.attendee).to be_empty
228-
expect(entry.summary).to eq "[My Project] Recurring meeting"
229-
expect(entry.description).to eq "[My Project] Meeting series: Recurring meeting"
228+
expect(entry.summary).to eq "Recurring meeting"
229+
expect(entry.description).to eq "Recurring meeting"
230230
expect(entry.location).to eq(recurring_meeting.template.location.presence)
231231
expect(entry.sequence).to eq(meeting.lock_version)
232232
expect(entry.status).to eq "CONFIRMED"

modules/meeting/spec/services/meetings/ical_service_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@
8484
expect(entry.attendee.map(&:to_s)).to contain_exactly("mailto:foo@example.com", "mailto:bob@example.com")
8585
expect(entry.dtstart.utc).to eq meeting.start_time
8686
expect(entry.dtend.utc).to eq meeting.start_time + 1.hour
87-
expect(entry.summary).to eq "[My Project] Important meeting"
88-
expect(entry.description).to eq "[My Project] Meeting: Important meeting"
87+
expect(entry.summary).to eq "Important meeting"
88+
expect(entry.description).to eq "Important meeting"
8989
expect(entry.location).to eq(meeting.location.presence)
9090
expect(entry.dtstart).to eq Time.zone.parse("2021-01-19T10:00:00Z").in_time_zone("Europe/Berlin")
9191
expect(entry.dtend).to eq (Time.zone.parse("2021-01-19T10:00:00Z") + 1.hour).in_time_zone("Europe/Berlin")
9292

9393
# do autogenerated ical timezone definitions match real DST switch times?
9494
standard = standard_zone.dtstart.to_time
95-
real_standard = Time.zone.parse("01-11-2020 01:00:00")
95+
real_standard = Time.zone.parse("01-11-2020 06:00:00")
9696
daylight = daylight_zone.dtstart.to_time
97-
real_daylight = Time.zone.parse("14-03-2021 03:00:00")
97+
real_daylight = Time.zone.parse("14-03-2021 07:00:00")
9898
expect(standard.strftime("%a, %d %b %Y %H:%M:%S")).to eq (real_standard.strftime("%a, %d %b %Y %H:%M:%S"))
9999
expect(daylight.strftime("%a, %d %b %Y %H:%M:%S")).to eq (real_daylight.strftime("%a, %d %b %Y %H:%M:%S"))
100100
end

modules/meeting/spec/services/meetings/icalendar_builder_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@
144144
expect(vtimezone_block).to be_present
145145
standard_count = vtimezone_block.scan("BEGIN:STANDARD").size
146146
daylight_count = vtimezone_block.scan("BEGIN:DAYLIGHT").size
147-
expect(standard_count).to eq(2)
148-
expect(daylight_count).to eq(2)
147+
expect(standard_count).to eq(4)
148+
expect(daylight_count).to eq(4)
149149
end
150150
end
151151
end

modules/meeting/spec/services/recurring_meetings/ical_service_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
it "contains serise and template information" do
7676
expect(parsed_events.count).to eq(1)
7777
expect(series_ical).to include("LOCATION:https://example.com/meet/important-meeting")
78-
expect(series_ical).to include("SUMMARY:[My Project] Weekly")
78+
expect(series_ical).to include("SUMMARY:Weekly")
7979
expect(series_ical).to include("CN=OpenProject:mailto:openproject@example.net")
8080
expect(series_ical).to include("ATTENDEE;CN=Bob Barker;EMAIL=bob@example.com;PARTSTAT=NEEDS-ACTION;RSVP=TRU")
8181
expect(series_ical).to include("ATTENDEE;CN=Foo Fooer;EMAIL=foo@example.com;PARTSTAT=NEEDS-ACTION;RSVP=TRUE")
@@ -97,7 +97,7 @@
9797
it "contains serise and template information" do
9898
expect(parsed_events.count).to eq(1)
9999
expect(series_ical).to include("LOCATION:https://example.com/meet/important-meeting")
100-
expect(series_ical).to include("SUMMARY:[My Project] Weekly")
100+
expect(series_ical).to include("SUMMARY:Weekly")
101101
expect(series_ical).to include("ATTENDEE;CN=Bob Barker;EMAIL=bob@example.com;PARTSTAT=NEEDS-ACTION;RSVP=TRU")
102102
expect(series_ical).to include("ATTENDEE;CN=Foo Fooer;EMAIL=foo@example.com;PARTSTAT=NEEDS-ACTION;RSVP=TRUE")
103103
expect(series_ical).to include("RRULE:FREQ=WEEKLY")

0 commit comments

Comments
 (0)