should not error for all_day events without date

fixes CORE-622
fixes CANVAS-3EPA

test plan
 - specs should pass

Change-Id: Ib824d38d51d35c8e97052019db6bcde2d5d37f8e
Reviewed-on: https://gerrit.instructure.com/132186
Tested-by: Jenkins
Reviewed-by: Felix Milea-Ciobanu <fmileaciobanu@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
This commit is contained in:
Rob Orton 2017-11-07 23:56:53 -07:00
parent 1692bdb35f
commit e91dec1a99
2 changed files with 6 additions and 1 deletions

View File

@ -666,7 +666,7 @@ class CalendarEvent < ActiveRecord::Base
event.end.icalendar_tzid = 'UTC'
end
if @event.all_day
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

View File

@ -184,6 +184,11 @@ describe CalendarEvent do
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
it 'should not fail with no date for all_day event' do
res = calendar_event_model(all_day: true).to_ics
expect(res).not_to be_nil
end
it "should return string dates for all_day events" do
calendar_event_model(:start_at => "Sep 3 2008 12:00am")
expect(@event.all_day).to eql(true)