upgrade icalendar to 2.5.1
test plan: * public feed should still work closes #COMMS-1720 Change-Id: I57092995f223e6545c24a39520fdce0ddb2fea78 Reviewed-on: https://gerrit.instructure.com/170447 Tested-by: Jenkins Reviewed-by: Steven Burnett <sburnett@instructure.com> QA-Review: Steven Burnett <sburnett@instructure.com> Product-Review: Steven Burnett <sburnett@instructure.com>
This commit is contained in:
parent
983403d665
commit
568d620270
|
@ -82,7 +82,7 @@ end
|
|||
gem 'i18nliner', '0.1.0'
|
||||
gem 'ruby2ruby', '2.4.1', require: false
|
||||
gem 'ruby_parser', '3.11.0', require: false
|
||||
gem 'icalendar', '1.5.4', require: false
|
||||
gem 'icalendar', '2.5.1', require: false
|
||||
gem 'ims-lti', '2.2.3', require: 'ims'
|
||||
gem 'json_schemer', '0.1.7'
|
||||
gem 'simple_oauth', '0.3.1', require: false
|
||||
|
|
|
@ -758,9 +758,9 @@ class CalendarEventsApiController < ApplicationController
|
|||
|
||||
calendar = Icalendar::Calendar.new
|
||||
# to appease Outlook
|
||||
calendar.custom_property("METHOD", "PUBLISH")
|
||||
calendar.custom_property("X-WR-CALNAME", name)
|
||||
calendar.custom_property("X-WR-CALDESC", description)
|
||||
calendar.append_custom_property("METHOD", "PUBLISH")
|
||||
calendar.append_custom_property("X-WR-CALNAME", name)
|
||||
calendar.append_custom_property("X-WR-CALDESC", description)
|
||||
|
||||
# scan the descriptions for attachments
|
||||
preloaded_attachments = api_bulk_load_user_content_attachments(@events.map(&:description))
|
||||
|
|
|
@ -20,7 +20,7 @@ require 'atom'
|
|||
require 'date'
|
||||
require 'icalendar'
|
||||
|
||||
Icalendar::Event.ical_property :x_alt_desc
|
||||
Icalendar::Event.optional_property :x_alt_desc
|
||||
|
||||
class CalendarEvent < ActiveRecord::Base
|
||||
include CopyAuthorizedLinks
|
||||
|
@ -600,37 +600,30 @@ class CalendarEvent < ActiveRecord::Base
|
|||
def to_ics(in_own_calendar:, preloaded_attachments: {}, include_description: false, user_events: [])
|
||||
cal = Icalendar::Calendar.new
|
||||
# to appease Outlook
|
||||
cal.custom_property("METHOD","PUBLISH")
|
||||
cal.append_custom_property("METHOD","PUBLISH")
|
||||
|
||||
event = Icalendar::Event.new
|
||||
event.klass = "PUBLIC"
|
||||
event.ip_class = "PUBLIC"
|
||||
|
||||
start_at = @event.is_a?(CalendarEvent) ? @event.start_at : @event.due_at
|
||||
end_at = @event.is_a?(CalendarEvent) ? @event.end_at : @event.due_at
|
||||
|
||||
if start_at
|
||||
event.start = start_at.utc_datetime
|
||||
event.start.icalendar_tzid = 'UTC'
|
||||
end
|
||||
|
||||
if end_at
|
||||
event.end = end_at.utc_datetime
|
||||
event.end.icalendar_tzid = 'UTC'
|
||||
end
|
||||
event.dtstart = Icalendar::Values::DateTime.new(start_at.utc_datetime, 'tzid' => 'UTC') if start_at
|
||||
event.dtend = Icalendar::Values::DateTime.new(end_at.utc_datetime, 'tzid' => 'UTC') if end_at
|
||||
|
||||
if @event.all_day && @event.all_day_date
|
||||
event.start = Date.new(@event.all_day_date.year, @event.all_day_date.month, @event.all_day_date.day)
|
||||
event.start.ical_params = {"VALUE"=>["DATE"]}
|
||||
event.end = event.start
|
||||
event.end.ical_params = {"VALUE"=>["DATE"]}
|
||||
event.dtstart = Date.new(@event.all_day_date.year, @event.all_day_date.month, @event.all_day_date.day)
|
||||
event.dtstart.ical_params = {"VALUE"=>["DATE"]}
|
||||
event.dtend = event.dtstart
|
||||
event.dtend.ical_params = {"VALUE"=>["DATE"]}
|
||||
end
|
||||
|
||||
event.summary = @event.title
|
||||
|
||||
if @event.description && include_description
|
||||
html = api_user_content(@event.description, @event.context, nil, preloaded_attachments)
|
||||
event.description html_to_text(html)
|
||||
event.x_alt_desc(html, { 'FMTTYPE' => 'text/html' })
|
||||
event.description = html_to_text(html)
|
||||
event.x_alt_desc = Icalendar::Values::Text.new(html, {'FMTTYPE' => 'text/html'})
|
||||
end
|
||||
|
||||
if @event.is_a?(CalendarEvent)
|
||||
|
@ -658,8 +651,7 @@ class CalendarEvent < ActiveRecord::Base
|
|||
end
|
||||
|
||||
event.location = loc_string
|
||||
event.dtstamp = @event.updated_at.utc_datetime if @event.updated_at
|
||||
event.dtstamp.icalendar_tzid = 'UTC' if event.dtstamp
|
||||
event.dtstamp = Icalendar::Values::DateTime.new(@event.updated_at.utc_datetime, 'tzid' => 'UTC') if @event.updated_at
|
||||
|
||||
tag_name = @event.class.name.underscore
|
||||
|
||||
|
@ -671,9 +663,9 @@ class CalendarEvent < ActiveRecord::Base
|
|||
|
||||
# This will change when there are other things that have calendars...
|
||||
# can't call calendar_url or calendar_url_for here, have to do it manually
|
||||
event.url "https://#{HostUrl.context_host(url_context)}/calendar?include_contexts=#{@event.context.asset_string}&month=#{start_at.try(:strftime, "%m")}&year=#{start_at.try(:strftime, "%Y")}##{tag_name}_#{@event.id}"
|
||||
event.uid "event-#{tag_name.gsub('_', '-')}-#{@event.id}"
|
||||
event.sequence 0
|
||||
event.url = "https://#{HostUrl.context_host(url_context)}/calendar?include_contexts=#{@event.context.asset_string}&month=#{start_at.try(:strftime, "%m")}&year=#{start_at.try(:strftime, "%Y")}##{tag_name}_#{@event.id}"
|
||||
event.uid = "event-#{tag_name.gsub('_', '-')}-#{@event.id}"
|
||||
event.sequence = 0
|
||||
|
||||
if @event.respond_to?(:applied_overrides)
|
||||
@event.applied_overrides.try(:each) do |override|
|
||||
|
|
|
@ -1163,8 +1163,8 @@ describe CalendarEventsApiController, type: :request do
|
|||
:controller => 'courses', :action => 'show', :format => 'json', :id => @course.id.to_s)
|
||||
get json['calendar']['ics']
|
||||
expect(response).to be_successful
|
||||
cal = Icalendar.parse(response.body.dup)[0]
|
||||
cal.events[0].x_alt_desc
|
||||
cal = Icalendar::Calendar.parse(response.body.dup)[0]
|
||||
cal.events[0].x_alt_desc.first
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1173,9 +1173,9 @@ describe CalendarEventsApiController, type: :request do
|
|||
assignment_model(description: "secret stuff here")
|
||||
get "/feeds/calendars/#{@course.feed_code}.ics"
|
||||
expect(response).to be_successful
|
||||
cal = Icalendar.parse(response.body.dup)[0]
|
||||
cal = Icalendar::Calendar.parse(response.body.dup)[0]
|
||||
expect(cal.events[0].description).to eq nil
|
||||
expect(cal.events[0].x_alt_desc).to eq nil
|
||||
expect(cal.events[0].x_alt_desc).to be_blank
|
||||
end
|
||||
|
||||
it 'works when event descriptions contain paths to user attachments' do
|
||||
|
@ -2279,7 +2279,7 @@ describe CalendarEventsApiController, type: :request do
|
|||
it "should include the appointment details in the teachers export" do
|
||||
get "/feeds/calendars/#{@teacher.feed_code}.ics"
|
||||
expect(response).to be_successful
|
||||
cal = Icalendar.parse(response.body.dup)[0]
|
||||
cal = Icalendar::Calendar.parse(response.body.dup)[0]
|
||||
appointment_text = "Unnamed Course\n" + "\n" + "Participants: \n" + "User\n" + "\n"
|
||||
expect(cal.events[1].description).to eq appointment_text
|
||||
expect(cal.events[2].description).to eq appointment_text
|
||||
|
@ -2288,7 +2288,7 @@ describe CalendarEventsApiController, type: :request do
|
|||
it "should not expose details of other students appts to a student" do
|
||||
get "/feeds/calendars/#{@user.feed_code}.ics"
|
||||
expect(response).to be_successful
|
||||
cal = Icalendar.parse(response.body.dup)[0]
|
||||
cal = Icalendar::Calendar.parse(response.body.dup)[0]
|
||||
expect(cal.events[1].description).to eq nil
|
||||
end
|
||||
|
||||
|
|
|
@ -3687,11 +3687,11 @@ describe Assignment do
|
|||
@assignment.updated_at = Time.at(1220443500) # 3 Sep 2008 12:05pm (UTC)
|
||||
res = @assignment.to_ics(in_own_calendar: false)
|
||||
expect(res).not_to be_nil
|
||||
expect(res.start.icalendar_tzid).to eq 'UTC'
|
||||
expect(res.start.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 11:55am").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.end.icalendar_tzid).to eq 'UTC'
|
||||
expect(res.end.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 11:55am").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.dtstamp.icalendar_tzid).to eq 'UTC'
|
||||
expect(res.dtstart.tz_utc).to eq true
|
||||
expect(res.dtstart.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 11:55am").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.dtend.tz_utc).to eq true
|
||||
expect(res.dtend.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 11:55am").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.dtstamp.tz_utc).to eq true
|
||||
expect(res.dtstamp.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 12:05pm").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
end
|
||||
|
||||
|
@ -3702,11 +3702,11 @@ describe Assignment do
|
|||
@assignment.updated_at = Time.at(1220472300) # 3 Sep 2008 12:05pm (AKDT)
|
||||
res = @assignment.to_ics(in_own_calendar: false)
|
||||
expect(res).not_to be_nil
|
||||
expect(res.start.icalendar_tzid).to eq 'UTC'
|
||||
expect(res.start.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 11:55am").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.end.icalendar_tzid).to eq 'UTC'
|
||||
expect(res.end.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 11:55am").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.dtstamp.icalendar_tzid).to eq 'UTC'
|
||||
expect(res.dtstart.tz_utc).to eq true
|
||||
expect(res.dtstart.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 11:55am").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.dtend.tz_utc).to eq true
|
||||
expect(res.dtend.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 11:55am").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.dtstamp.tz_utc).to eq true
|
||||
expect(res.dtstamp.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 12:05pm").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
end
|
||||
|
||||
|
|
|
@ -187,11 +187,11 @@ describe CalendarEvent do
|
|||
@event.updated_at = Time.at(1220443500) # 3 Sep 2008 12:05pm (UTC)
|
||||
res = @event.to_ics(in_own_calendar: false)
|
||||
expect(res).not_to be_nil
|
||||
expect(res.start.icalendar_tzid).to eq 'UTC'
|
||||
expect(res.start.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 11:55am").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.end.icalendar_tzid).to eq 'UTC'
|
||||
expect(res.end.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 12:00pm").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.dtstamp.icalendar_tzid).to eq 'UTC'
|
||||
expect(res.dtstart.tz_utc).to eq true
|
||||
expect(res.dtstart.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 11:55am").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.dtend.tz_utc).to eq true
|
||||
expect(res.dtend.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 12:00pm").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.dtstamp.tz_utc).to eq true
|
||||
expect(res.dtstamp.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 12:05pm").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
end
|
||||
|
||||
|
@ -202,11 +202,11 @@ describe CalendarEvent do
|
|||
@event.updated_at = Time.at(1220472300) # 3 Sep 2008 12:05pm (AKDT)
|
||||
res = @event.to_ics(in_own_calendar: false)
|
||||
expect(res).not_to be_nil
|
||||
expect(res.start.icalendar_tzid).to eq 'UTC'
|
||||
expect(res.start.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 11:55am").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.end.icalendar_tzid).to eq 'UTC'
|
||||
expect(res.end.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 12:00pm").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.end.icalendar_tzid).to eq 'UTC'
|
||||
expect(res.dtstart.tz_utc).to eq true
|
||||
expect(res.dtstart.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 11:55am").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.dtend.tz_utc).to eq true
|
||||
expect(res.dtend.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 12:00pm").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
expect(res.dtend.tz_utc).to eq true
|
||||
expect(res.dtstamp.strftime('%Y-%m-%dT%H:%M:%S')).to eq Time.zone.parse("Sep 3 2008 12:05pm").in_time_zone('UTC').strftime('%Y-%m-%dT%H:%M:00')
|
||||
end
|
||||
|
||||
|
@ -237,7 +237,7 @@ describe CalendarEvent do
|
|||
|
||||
|
||||
[link!](www.example.com)")
|
||||
expect(ev.x_alt_desc).to eq @event.description
|
||||
expect(ev.x_alt_desc.first).to eq @event.description
|
||||
end
|
||||
|
||||
it "should not add verifiers to files unless course or attachment is public" do
|
||||
|
|
Loading…
Reference in New Issue