slashk
2010-Mar-15 05:30 UTC
[iCalendar-devel] icalender v1.1.2 causes error in to_ical with multiple events
I upgraded my icalendar gem to version 1.1.2 this week (from v1.1.0) and I am
now getting errors in my rails test (stable for over a year).
Here is the error from my rails rake task:
test_should_get_tag_calendar ERROR
NoMethodError: Method Name: <=>
icalendar (1.1.2) lib/icalendar/component.rb:419:in
`method_missing''
icalendar (1.1.2) lib/icalendar/component.rb:107:in `sort''
icalendar (1.1.2) lib/icalendar/component.rb:107:in `to_ical''
icalendar (1.1.2) lib/icalendar/component.rb:106:in `each''
icalendar (1.1.2) lib/icalendar/component.rb:106:in `to_ical''
icalendar (1.1.2) lib/icalendar/component.rb:122:in
`print_component''
icalendar (1.1.2) lib/icalendar/component.rb:104:in `to_ical''
app/controllers/application_controller.rb:60:in `create_calendar''
app/controllers/calendar_controller.rb:72:in `tags''
app/controllers/calendar_controller.rb:70:in `tags''
/test/functional/calendar_controller_test.rb:129:in
`test_should_get_tag_calendar''
The problem seems to have been introduced in github commit
29f8371b1cc8f057723bdafa11fecfe7210e1a82, where "sort" was added into
the enumeration chain in line 107 of the component.rb file.
I can reproduce this bug with this test in the icalendar source from github
(git://github.com/sdague/icalendar.git) :
def test_create_multiple_event_calendar
# Create a fresh calendar
cal = Calendar.new
[1,2,3].each do |t|
cal.event do
self.dtend = "1997090#{t}T190000Z"
self.summary = "This is summary #{t}"
end
end
[1,2,3].each do |t|
cal.todo do
self.name = "test #{t} todo"
end
end
cal.to_ical
end
You can also reproduce this bug by following the example in the README.rdoc
file.
I believe I am correctly using .to_ical here (at least that''s how I
been using it). when I add this test to test_calendar.rb, it results in:
1) Error:
test_create_multiple_event_calendar(TestCalendar):
NoMethodError: Method Name: <=>
./lib/icalendar/component.rb:423:in `method_missing''
./lib/icalendar/component.rb:111:in `sort''
./lib/icalendar/component.rb:111:in `to_ical''
./lib/icalendar/component.rb:110:in `each''
./lib/icalendar/component.rb:110:in `to_ical''
./lib/icalendar/component.rb:126:in `print_component''
./lib/icalendar/component.rb:108:in `to_ical''
./test/test_calendar.rb:43:in `test_create_multiple_event_calendar''
My ruby-fu is weak, but I believe we need to add code to tell it to sort our
component objects, something like:
def <=>(other)
self.properties[''uid''] <=>
other.properties[''uid'']
end
in the Component class (maybe in lib/icalendar/component.rb ?). I''m not
sure if uid actually applies to all components however. When I do try this, it
fixes the multiple events but still errors on the multiple todos --- so maybe
this is supposed to go somewhere else ?
Any help ?
P.S. I am using ruby 1.8.7 (2008-08-11 patchlevel 72) and the following gems:
hoe (2.5.0, 2.3.3, 1.12.2)
gemcutter (0.5.0, 0.4.1)
rails (2.3.5, 2.3.4, 2.2.2, 2.1.2, 1.2.6)
---
/k
http://www.mtbcalendar.com
http://norcalmtnbikeracing.blogspot.com
norcalmtbracing at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/icalendar-devel/attachments/20100314/e5de7e1d/attachment.html>
Sean Dague
2010-Mar-15 12:41 UTC
[iCalendar-devel] icalender v1.1.2 causes error in to_ical with multiple events
On 03/15/2010 01:30 AM, slashk wrote:> I upgraded my icalendar gem to version 1.1.2 this week (from v1.1.0) and > I am now getting errors in my rails test (stable for over a year).I was trying some things to get the tests to run correctly on multiple ruby verisons.... and I apparently failed pretty badly at it. Thanks for the new test, I just integrated and pushed a 1.1.3 which reverts the sorts. I''ll look into your approach to do the sorts correctly later, because it would be nice to have items in the ical show up in a predictable order, instead of hash order, which is definitely different between 1.8.6 and 1.8.7. Please let me know if 1.1.3 works for you, -Sean -- __________________________________________________________________ Sean Dague Mid-Hudson Valley sean at dague dot net Linux Users Group http://dague.net http://mhvlug.org There is no silver bullet. Plus, werewolves make better neighbors than zombies, and they tend to keep the vampire population down. __________________________________________________________________ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 253 bytes Desc: OpenPGP digital signature URL: <http://rubyforge.org/pipermail/icalendar-devel/attachments/20100315/772844f9/attachment-0001.bin>
slashk
2010-Mar-16 00:12 UTC
[iCalendar-devel] icalender v1.1.2 causes error in to_ical with multiple events
On Mar 15, 2010, at 5:49 AM, icalendar-devel-request at rubyforge.org wrote:> > Thanks for the new test, I just integrated and pushed a 1.1.3 which > reverts the sorts.Yep, v1.1.3 fixed it. Thanks