tilia-vobject 4.0.0.pre.alpha5 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.sabre.md +59 -2
  3. data/Gemfile +1 -8
  4. data/Gemfile.lock +18 -12
  5. data/LICENSE +1 -1
  6. data/LICENSE.sabre +1 -1
  7. data/lib/tilia/v_object.rb +1 -0
  8. data/lib/tilia/v_object/birthday_calendar_generator.rb +11 -11
  9. data/lib/tilia/v_object/cli.rb +39 -38
  10. data/lib/tilia/v_object/component.rb +47 -50
  11. data/lib/tilia/v_object/component/available.rb +4 -37
  12. data/lib/tilia/v_object/component/v_alarm.rb +6 -18
  13. data/lib/tilia/v_object/component/v_availability.rb +6 -39
  14. data/lib/tilia/v_object/component/v_calendar.rb +66 -98
  15. data/lib/tilia/v_object/component/v_card.rb +42 -69
  16. data/lib/tilia/v_object/component/v_event.rb +5 -17
  17. data/lib/tilia/v_object/component/v_free_busy.rb +4 -16
  18. data/lib/tilia/v_object/component/v_journal.rb +16 -16
  19. data/lib/tilia/v_object/component/v_time_zone.rb +2 -14
  20. data/lib/tilia/v_object/component/v_todo.rb +17 -36
  21. data/lib/tilia/v_object/date_time_parser.rb +24 -24
  22. data/lib/tilia/v_object/document.rb +25 -25
  23. data/lib/tilia/v_object/free_busy_data.rb +7 -7
  24. data/lib/tilia/v_object/free_busy_generator.rb +73 -75
  25. data/lib/tilia/v_object/i_tip.rb +1 -0
  26. data/lib/tilia/v_object/i_tip/broker.rb +134 -116
  27. data/lib/tilia/v_object/i_tip/i_tip_exception.rb +1 -1
  28. data/lib/tilia/v_object/i_tip/message.rb +13 -13
  29. data/lib/tilia/v_object/invalid_data_exception.rb +8 -0
  30. data/lib/tilia/v_object/node.rb +22 -27
  31. data/lib/tilia/v_object/parameter.rb +22 -22
  32. data/lib/tilia/v_object/parse_exception.rb +1 -1
  33. data/lib/tilia/v_object/parser.rb +1 -0
  34. data/lib/tilia/v_object/parser/json.rb +9 -19
  35. data/lib/tilia/v_object/parser/mime_dir.rb +73 -39
  36. data/lib/tilia/v_object/parser/parser.rb +9 -14
  37. data/lib/tilia/v_object/parser/xml.rb +33 -50
  38. data/lib/tilia/v_object/parser/xml/element.rb +1 -0
  39. data/lib/tilia/v_object/parser/xml/element/key_value.rb +2 -2
  40. data/lib/tilia/v_object/property.rb +52 -52
  41. data/lib/tilia/v_object/property/binary.rb +10 -10
  42. data/lib/tilia/v_object/property/boolean.rb +6 -6
  43. data/lib/tilia/v_object/property/flat_text.rb +3 -3
  44. data/lib/tilia/v_object/property/float_value.rb +10 -10
  45. data/lib/tilia/v_object/property/i_calendar.rb +1 -0
  46. data/lib/tilia/v_object/property/i_calendar/cal_address.rb +3 -3
  47. data/lib/tilia/v_object/property/i_calendar/date_time.rb +29 -57
  48. data/lib/tilia/v_object/property/i_calendar/duration.rb +6 -6
  49. data/lib/tilia/v_object/property/i_calendar/period.rb +10 -10
  50. data/lib/tilia/v_object/property/i_calendar/recur.rb +16 -24
  51. data/lib/tilia/v_object/property/integer_value.rb +8 -8
  52. data/lib/tilia/v_object/property/text.rb +21 -36
  53. data/lib/tilia/v_object/property/time.rb +29 -6
  54. data/lib/tilia/v_object/property/unknown.rb +2 -2
  55. data/lib/tilia/v_object/property/uri.rb +24 -5
  56. data/lib/tilia/v_object/property/utc_offset.rb +5 -5
  57. data/lib/tilia/v_object/property/v_card.rb +1 -0
  58. data/lib/tilia/v_object/property/v_card/date.rb +3 -3
  59. data/lib/tilia/v_object/property/v_card/date_and_or_time.rb +30 -42
  60. data/lib/tilia/v_object/property/v_card/date_time.rb +1 -1
  61. data/lib/tilia/v_object/property/v_card/language_tag.rb +4 -4
  62. data/lib/tilia/v_object/property/v_card/time_stamp.rb +5 -5
  63. data/lib/tilia/v_object/reader.rb +12 -11
  64. data/lib/tilia/v_object/recur.rb +2 -0
  65. data/lib/tilia/v_object/recur/event_iterator.rb +30 -27
  66. data/lib/tilia/v_object/recur/max_instances_exceeded_exception.rb +10 -0
  67. data/lib/tilia/v_object/recur/no_instances_exception.rb +1 -1
  68. data/lib/tilia/v_object/recur/r_date_iterator.rb +15 -41
  69. data/lib/tilia/v_object/recur/r_rule_iterator.rb +23 -156
  70. data/lib/tilia/v_object/settings.rb +16 -0
  71. data/lib/tilia/v_object/splitter.rb +1 -0
  72. data/lib/tilia/v_object/splitter/i_calendar.rb +5 -5
  73. data/lib/tilia/v_object/splitter/splitter_interface.rb +2 -2
  74. data/lib/tilia/v_object/splitter/v_card.rb +5 -5
  75. data/lib/tilia/v_object/string_util.rb +25 -9
  76. data/lib/tilia/v_object/time_zone_data.rb +1 -0
  77. data/lib/tilia/v_object/time_zone_util.rb +6 -6
  78. data/lib/tilia/v_object/uuid_util.rb +3 -3
  79. data/lib/tilia/v_object/v_card_converter.rb +24 -21
  80. data/lib/tilia/v_object/version.rb +1 -1
  81. data/lib/tilia/v_object/writer.rb +7 -7
  82. data/test/test_helper.rb +3 -3
  83. data/test/v_object/birthday_calendar_generator_test.rb +22 -0
  84. data/test/v_object/component/v_alarm_test.rb +3 -1
  85. data/test/v_object/component/v_calendar_test.rb +40 -4
  86. data/test/v_object/component/v_card_test.rb +1 -1
  87. data/test/v_object/component_test.rb +5 -3
  88. data/test/v_object/date_time_parser_test.rb +15 -5
  89. data/test/v_object/free_busy_generator_test.rb +5 -5
  90. data/test/v_object/i_tip/broker_attendee_reply_test.rb +19 -0
  91. data/test/v_object/i_tip/broker_delete_event_test.rb +146 -2
  92. data/test/v_object/i_tip/broker_new_event_test.rb +21 -0
  93. data/test/v_object/i_tip/broker_process_reply_test.rb +10 -0
  94. data/test/v_object/i_tip/broker_tester.rb +1 -1
  95. data/test/v_object/i_tip/broker_update_event_test.rb +36 -0
  96. data/test/v_object/issue259_test.rb +24 -0
  97. data/test/v_object/issue40_test.rb +3 -1
  98. data/test/v_object/j_cal_test.rb +15 -12
  99. data/test/v_object/parser/json_test.rb +5 -5
  100. data/test/v_object/parser/mime_dir_test.rb +109 -0
  101. data/test/v_object/property/binary_test.rb +4 -2
  102. data/test/v_object/property/i_calendar/date_time_test.rb +3 -1
  103. data/test/v_object/property/uri_test.rb +23 -0
  104. data/test/v_object/recur/event_iterator/by_month_in_daily_test.rb +1 -1
  105. data/test/v_object/recur/event_iterator/by_set_pos_hang_test.rb +1 -1
  106. data/test/v_object/recur/event_iterator/expand_floating_times_test.rb +9 -9
  107. data/test/v_object/recur/event_iterator/handle_r_date_expand_test.rb +51 -0
  108. data/test/v_object/recur/event_iterator/incorrect_expand_test.rb +3 -5
  109. data/test/v_object/recur/event_iterator/infinite_loop_problem_test.rb +3 -1
  110. data/test/v_object/{issue26_test.rb → recur/event_iterator/issue26_test.rb} +3 -1
  111. data/test/v_object/recur/event_iterator/main_test.rb +9 -3
  112. data/test/v_object/recur/event_iterator/max_instances_test.rb +38 -0
  113. data/test/v_object/recur/event_iterator/missing_overridden_test.rb +3 -5
  114. data/test/v_object/recur/event_iterator/no_instances_test.rb +5 -3
  115. data/test/v_object/recur/event_iterator/override_first_event_test.rb +9 -9
  116. data/test/v_object/recur/r_date_iterator_test.rb +18 -0
  117. data/test/v_object/recur/r_rule_iterator_test.rb +4 -4
  118. data/test/v_object/splitter/i_calendar_test.rb +27 -7
  119. data/test/v_object/splitter/v_card_test.rb +5 -3
  120. data/test/v_object/test_case.rb +14 -4
  121. data/tilia-vobject.gemspec +2 -2
  122. metadata +17 -11
@@ -4,8 +4,10 @@ module Tilia
4
4
  module VObject
5
5
  class BinaryTest < Minitest::Test
6
6
  def test_mime_dir
7
- vcard = Tilia::VObject::Component::VCard.new
8
- assert_raises(ArgumentError) { vcard.add('PHOTO', ['a', 'b']) }
7
+ vcard = Tilia::VObject::Component::VCard.new('VERSION' => '3.0')
8
+ assert_raises(ArgumentError) do
9
+ vcard.add('PHOTO', ['a', 'b'])
10
+ end
9
11
  end
10
12
  end
11
13
  end
@@ -224,7 +224,9 @@ module Tilia
224
224
 
225
225
  def test_get_date_time_date_invalid
226
226
  elem = @vcal.create_property('DTSTART', 'bla')
227
- assert_raises(RuntimeError) { elem.date_time }
227
+ assert_raises(InvalidDataException) do
228
+ elem.date_time
229
+ end
228
230
  end
229
231
 
230
232
  def test_get_date_time_weird_tz
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+ module Tilia
4
+ module VObject
5
+ class UriTest < Minitest::Test
6
+ def test_always_encode_uri_v_calendar
7
+ # Apple iCal has issues with URL properties that don't have
8
+ # VALUE=URI specified. We added a workaround to vobject that
9
+ # ensures VALUE=URI always appears for these.
10
+ input = <<ICS
11
+ BEGIN:VCALENDAR
12
+ VERSION:2.0
13
+ BEGIN:VEVENT
14
+ URL:http://example.org/
15
+ END:VEVENT
16
+ END:VCALENDAR
17
+ ICS
18
+ output = Reader.read(input).serialize
19
+ assert(output.index('URL;VALUE=URI:http://example.org/'))
20
+ end
21
+ end
22
+ end
23
+ end
@@ -29,7 +29,7 @@ ICS
29
29
  vcal = Tilia::VObject::Reader.read(ics)
30
30
  assert_kind_of(Tilia::VObject::Component::VCalendar, vcal)
31
31
 
32
- vcal.expand(Time.zone.parse('2013-09-28'), Time.zone.parse('2014-09-11'))
32
+ vcal = vcal.expand(Time.zone.parse('2013-09-28'), Time.zone.parse('2014-09-11'))
33
33
 
34
34
  dates = []
35
35
  vcal['VEVENT'].each do |event|
@@ -25,7 +25,7 @@ ICS
25
25
  vcal = Tilia::VObject::Reader.read(ics)
26
26
  assert_kind_of(Tilia::VObject::Component::VCalendar, vcal)
27
27
 
28
- vcal.expand(Time.zone.parse('2015-01-01'), Time.zone.parse('2016-01-01'))
28
+ vcal = vcal.expand(Time.zone.parse('2015-01-01'), Time.zone.parse('2016-01-01'))
29
29
 
30
30
  dates = []
31
31
  vcal['VEVENT'].each do |event|
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  module Tilia
4
4
  module VObject
5
- class ExpandFloatingTimesTest < Minitest::Test
5
+ class ExpandFloatingTimesTest < TestCase
6
6
  def test_expand
7
7
  input = <<ICS
8
8
  BEGIN:VCALENDAR
@@ -19,9 +19,7 @@ ICS
19
19
  vcal = Tilia::VObject::Reader.read(input)
20
20
  assert_kind_of(Tilia::VObject::Component::VCalendar, vcal)
21
21
 
22
- vcal.expand(Time.zone.parse('2015-01-01'), Time.zone.parse('2015-01-31'))
23
-
24
- result = vcal.serialize
22
+ vcal = vcal.expand(Time.zone.parse('2015-01-01'), Time.zone.parse('2015-01-31'))
25
23
 
26
24
  output = <<ICS
27
25
  BEGIN:VCALENDAR
@@ -51,7 +49,7 @@ RECURRENCE-ID:20150130T090000Z
51
49
  END:VEVENT
52
50
  END:VCALENDAR
53
51
  ICS
54
- assert_equal(output, result.delete("\r"))
52
+ assert_v_obj_equals(output, vcal)
55
53
  end
56
54
 
57
55
  def test_expand_with_reference_timezone
@@ -70,9 +68,11 @@ ICS
70
68
  vcal = Tilia::VObject::Reader.read(input)
71
69
  assert_kind_of(Tilia::VObject::Component::VCalendar, vcal)
72
70
 
73
- vcal.expand(Time.zone.parse('2015-01-01'), Time.zone.parse('2015-01-31'), ActiveSupport::TimeZone.new('Europe/Berlin'))
74
-
75
- result = vcal.serialize
71
+ vcal = vcal.expand(
72
+ Time.zone.parse('2015-01-01'),
73
+ Time.zone.parse('2015-01-31'),
74
+ ActiveSupport::TimeZone.new('Europe/Berlin')
75
+ )
76
76
 
77
77
  output = <<ICS
78
78
  BEGIN:VCALENDAR
@@ -102,7 +102,7 @@ RECURRENCE-ID:20150130T080000Z
102
102
  END:VEVENT
103
103
  END:VCALENDAR
104
104
  ICS
105
- assert_equal(output, result.delete("\r"))
105
+ assert_v_obj_equals(output, vcal)
106
106
  end
107
107
  end
108
108
  end
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+
3
+ module Tilia
4
+ module VObject
5
+ # This is a unittest for Issue #53.
6
+ class HandleRDateExpandTest < Minitest::Test
7
+ def test_expand
8
+ input = <<ICS
9
+ BEGIN:VCALENDAR
10
+ VERSION:2.0
11
+ BEGIN:VEVENT
12
+ UID:2CD5887F7CF4600F7A3B1F8065099E40-240BDA7121B61224
13
+ DTSTAMP;VALUE=DATE-TIME:20151014T110604Z
14
+ CREATED;VALUE=DATE-TIME:20151014T110245Z
15
+ LAST-MODIFIED;VALUE=DATE-TIME:20151014T110541Z
16
+ DTSTART;VALUE=DATE-TIME;TZID=Europe/Berlin:20151012T020000
17
+ DTEND;VALUE=DATE-TIME;TZID=Europe/Berlin:20151012T013000
18
+ SUMMARY:Test
19
+ SEQUENCE:2
20
+ RDATE;VALUE=DATE-TIME;TZID=Europe/Berlin:20151015T020000,20151017T020000,20
21
+ 151018T020000,20151020T020000
22
+ TRANSP:OPAQUE
23
+ CLASS:PUBLIC
24
+ END:VEVENT
25
+ END:VCALENDAR
26
+ ICS
27
+
28
+ vcal = VObject::Reader.read(input)
29
+ assert_kind_of(Component::VCalendar, vcal)
30
+
31
+ vcal = vcal.expand(Time.zone.parse('2015-01-01'), Time.zone.parse('2015-12-01'))
32
+
33
+ result = vcal['VEVENT'].to_a
34
+
35
+ assert_equal(5, result.size)
36
+
37
+ utc = ActiveSupport::TimeZone.new('UTC')
38
+ expected = [
39
+ utc.parse('2015-10-12'),
40
+ utc.parse('2015-10-15'),
41
+ utc.parse('2015-10-17'),
42
+ utc.parse('2015-10-18'),
43
+ utc.parse('2015-10-20')
44
+ ]
45
+
46
+ result = result.map { |ev| ev['DTSTART'].date_time }
47
+ assert_equal(expected, result)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  module Tilia
4
4
  module VObject
5
5
  # This is a unittest for Issue #53.
6
- class IncorrectExpandTest < Minitest::Test
6
+ class IncorrectExpandTest < TestCase
7
7
  def test_expand
8
8
  input = <<ICS
9
9
  BEGIN:VCALENDAR
@@ -26,9 +26,7 @@ ICS
26
26
  vcal = Tilia::VObject::Reader.read(input)
27
27
  assert_kind_of(Tilia::VObject::Component::VCalendar, vcal)
28
28
 
29
- vcal.expand(Time.zone.parse('2011-01-01'), Time.zone.parse('2014-01-01'))
30
-
31
- result = vcal.serialize
29
+ vcal = vcal.expand(Time.zone.parse('2011-01-01'), Time.zone.parse('2014-01-01'))
32
30
 
33
31
  output = <<ICS
34
32
  BEGIN:VCALENDAR
@@ -46,7 +44,7 @@ RECURRENCE-ID:20130712T050000Z
46
44
  END:VEVENT
47
45
  END:VCALENDAR
48
46
  ICS
49
- assert_equal(output, result.delete("\r"))
47
+ assert_v_obj_equals(output, vcal)
50
48
  end
51
49
  end
52
50
  end
@@ -65,7 +65,9 @@ module Tilia
65
65
  ev['RRULE'] = 'FREQ=YEARLY;INTERVAL=0'
66
66
  @vcal.add(ev)
67
67
 
68
- assert_raises(ArgumentError) { Tilia::VObject::Recur::EventIterator.new(@vcal, 'uuid') }
68
+ assert_raises(InvalidDataException) do
69
+ Tilia::VObject::Recur::EventIterator.new(@vcal, 'uuid')
70
+ end
69
71
  # it.fast_forward(ActiveSupport::TimeZone.new('UTC').parse('2013-01-01 23:00:00'))
70
72
 
71
73
  # if we got this far.. it means we are no longer infinitely looping
@@ -18,7 +18,9 @@ ICS
18
18
  vcal = Tilia::VObject::Reader.read(input)
19
19
  assert_kind_of(Tilia::VObject::Component::VCalendar, vcal)
20
20
 
21
- assert_raises(ArgumentError) { Tilia::VObject::Recur::EventIterator.new(vcal, 'bae5d57a98') }
21
+ assert_raises(InvalidDataException) do
22
+ Tilia::VObject::Recur::EventIterator.new(vcal, 'bae5d57a98')
23
+ end
22
24
  end
23
25
  end
24
26
  end
@@ -31,17 +31,23 @@ module Tilia
31
31
  ev.add(dt_start)
32
32
  vcal.add(ev)
33
33
 
34
- assert_raises(ArgumentError) { Tilia::VObject::Recur::EventIterator.new(vcal, ev['UID'].to_s) }
34
+ assert_raises(InvalidDataException) do
35
+ Tilia::VObject::Recur::EventIterator.new(vcal, ev['UID'].to_s)
36
+ end
35
37
  end
36
38
 
37
39
  def test_v_calendar_no_uid
38
40
  vcal = Tilia::VObject::Component::VCalendar.new
39
- assert_raises(ArgumentError) { Tilia::VObject::Recur::EventIterator.new(vcal) }
41
+ assert_raises(ArgumentError) do
42
+ Tilia::VObject::Recur::EventIterator.new(vcal)
43
+ end
40
44
  end
41
45
 
42
46
  def test_v_calendar_invalid_uid
43
47
  vcal = Tilia::VObject::Component::VCalendar.new
44
- assert_raises(ArgumentError) { Tilia::VObject::Recur::EventIterator.new(vcal, 'foo') }
48
+ assert_raises(ArgumentError) do
49
+ Tilia::VObject::Recur::EventIterator.new(vcal, 'foo')
50
+ end
45
51
  end
46
52
 
47
53
  def test_hourly
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ module Tilia
4
+ module VObject
5
+ class MaxInstancesTest < TestCase
6
+ def setup
7
+ @max_recurrences = Settings.max_recurrences
8
+ Settings.max_recurrences = 4
9
+
10
+ super
11
+ end
12
+
13
+ def teardown
14
+ Settings.max_recurrences = @max_recurrences
15
+ super
16
+ end
17
+
18
+ def test_exceed_max_recurrences
19
+ input = <<ICS
20
+ BEGIN:VCALENDAR
21
+ VERSION:2.0
22
+ BEGIN:VEVENT
23
+ UID:foobar
24
+ DTSTART:20140803T120000Z
25
+ RRULE:FREQ=WEEKLY
26
+ SUMMARY:Original
27
+ END:VEVENT
28
+ END:VCALENDAR
29
+ ICS
30
+
31
+ vcal = Reader.read(input)
32
+ assert_raises(Recur::MaxInstancesExceededException) do
33
+ vcal.expand(Time.zone.parse('2014-08-01'), Time.zone.parse('2014-09-01'))
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  module Tilia
4
4
  module VObject
5
- class MissingOverriddenTest < Minitest::Test
5
+ class MissingOverriddenTest < TestCase
6
6
  def test_expand
7
7
  input = <<ICS
8
8
  BEGIN:VCALENDAR
@@ -26,9 +26,7 @@ ICS
26
26
  vcal = Tilia::VObject::Reader.read(input)
27
27
  assert_kind_of(Tilia::VObject::Component::VCalendar, vcal)
28
28
 
29
- vcal.expand(Time.zone.parse('2011-01-01'), Time.zone.parse('2015-01-01'))
30
-
31
- result = vcal.serialize
29
+ vcal = vcal.expand(Time.zone.parse('2011-01-01'), Time.zone.parse('2015-01-01'))
32
30
 
33
31
  output = <<ICS
34
32
  BEGIN:VCALENDAR
@@ -48,7 +46,7 @@ SUMMARY:B
48
46
  END:VEVENT
49
47
  END:VCALENDAR
50
48
  ICS
51
- assert_equal(output, result.delete("\r"))
49
+ assert_v_obj_equals(output, vcal)
52
50
  end
53
51
  end
54
52
  end
@@ -22,10 +22,12 @@ END:VEVENT
22
22
  END:VCALENDAR
23
23
  ICS
24
24
 
25
- vcal = Tilia::VObject::Reader.read(input)
26
- assert_kind_of(Tilia::VObject::Component::VCalendar, vcal)
25
+ vcal = Reader.read(input)
26
+ assert_kind_of(Component::VCalendar, vcal)
27
27
 
28
- assert_raises(Tilia::VObject::Recur::NoInstancesException) { Tilia::VObject::Recur::EventIterator.new(vcal, 'foo') }
28
+ assert_raises(Recur::NoInstancesException) do
29
+ Recur::EventIterator.new(vcal, 'foo')
30
+ end
29
31
  end
30
32
  end
31
33
  end
@@ -2,10 +2,11 @@ require 'test_helper'
2
2
 
3
3
  module Tilia
4
4
  module VObject
5
- class OverrideFirstEventTest < Minitest::Test
5
+ class OverrideFirstEventTest < TestCase
6
6
  def test_override_first_event
7
7
  input = <<ICS
8
8
  BEGIN:VCALENDAR
9
+ VERSION:2.0
9
10
  BEGIN:VEVENT
10
11
  UID:foobar
11
12
  DTSTART:20140803T120000Z
@@ -22,10 +23,11 @@ END:VCALENDAR
22
23
  ICS
23
24
 
24
25
  vcal = Tilia::VObject::Reader.read(input)
25
- vcal.expand(Time.zone.parse('2014-08-01'), Time.zone.parse('2014-09-01'))
26
+ vcal = vcal.expand(Time.zone.parse('2014-08-01'), Time.zone.parse('2014-09-01'))
26
27
 
27
28
  expected = <<ICS
28
29
  BEGIN:VCALENDAR
30
+ VERSION:2.0
29
31
  BEGIN:VEVENT
30
32
  UID:foobar
31
33
  RECURRENCE-ID:20140803T120000Z
@@ -59,14 +61,13 @@ END:VEVENT
59
61
  END:VCALENDAR
60
62
  ICS
61
63
 
62
- new_ics = vcal.serialize
63
- new_ics = new_ics.delete("\r")
64
- assert_equal(expected, new_ics)
64
+ assert_v_obj_equals(expected, vcal)
65
65
  end
66
66
 
67
67
  def test_remove_first_event
68
68
  input = <<ICS
69
69
  BEGIN:VCALENDAR
70
+ VERSION:2.0
70
71
  BEGIN:VEVENT
71
72
  UID:foobar
72
73
  DTSTART:20140803T120000Z
@@ -78,10 +79,11 @@ END:VCALENDAR
78
79
  ICS
79
80
 
80
81
  vcal = Tilia::VObject::Reader.read(input)
81
- vcal.expand(Time.zone.parse('2014-08-01'), Time.zone.parse('2014-08-19'))
82
+ vcal = vcal.expand(Time.zone.parse('2014-08-01'), Time.zone.parse('2014-08-19'))
82
83
 
83
84
  expected = <<ICS
84
85
  BEGIN:VCALENDAR
86
+ VERSION:2.0
85
87
  BEGIN:VEVENT
86
88
  UID:foobar
87
89
  DTSTART:20140810T120000Z
@@ -97,9 +99,7 @@ END:VEVENT
97
99
  END:VCALENDAR
98
100
  ICS
99
101
 
100
- new_ics = vcal.serialize
101
- new_ics = new_ics.delete("\r")
102
- assert_equal(expected, new_ics)
102
+ assert_v_obj_equals(expected, vcal)
103
103
  end
104
104
  end
105
105
  end
@@ -18,6 +18,24 @@ module Tilia
18
18
  refute(it.infinite?)
19
19
  end
20
20
 
21
+ def test_timezone
22
+ tz = ActiveSupport::TimeZone.new('Europe/Berlin')
23
+ it = Recur::RDateIterator.new('20140901T000000,20141001T000000', tz.parse('2014-08-01 00:00:00'))
24
+
25
+ expected = [
26
+ tz.parse('2014-08-01 00:00:00'),
27
+ tz.parse('2014-09-01 00:00:00'),
28
+ tz.parse('2014-10-01 00:00:00')
29
+ ]
30
+
31
+ assert_equal(
32
+ expected,
33
+ it.to_a
34
+ )
35
+
36
+ refute(it.infinite?)
37
+ end
38
+
21
39
  def test_fast_forward
22
40
  utc = ActiveSupport::TimeZone.new('UTC')
23
41
  it = Tilia::VObject::Recur::RDateIterator.new('20140901T000000Z,20141001T000000Z', utc.parse('2014-08-01 00:00:00'))
@@ -496,7 +496,7 @@ module Tilia
496
496
  # this means we increase the current day (or week, month) by 0, this also
497
497
  # results in an infinite loop.
498
498
  def test_zero_interval
499
- assert_raises(ArgumentError) do
499
+ assert_raises(InvalidDataException) do
500
500
  parse(
501
501
  'FREQ=YEARLY;INTERVAL=0',
502
502
  '2012-08-24 14:57:00',
@@ -507,7 +507,7 @@ module Tilia
507
507
  end
508
508
 
509
509
  def test_invalid_freq
510
- assert_raises(ArgumentError) do
510
+ assert_raises(InvalidDataException) do
511
511
  parse(
512
512
  'FREQ=SMONTHLY;INTERVAL=3;UNTIL=20111025T000000Z',
513
513
  '2011-10-07',
@@ -517,7 +517,7 @@ module Tilia
517
517
  end
518
518
 
519
519
  def test_by_day_bad_offset
520
- assert_raises(ArgumentError) do
520
+ assert_raises(InvalidDataException) do
521
521
  parse(
522
522
  'FREQ=WEEKLY;INTERVAL=1;COUNT=4;BYDAY=0MO;WKST=SA',
523
523
  '2014-08-01 00:00:00',
@@ -581,7 +581,7 @@ module Tilia
581
581
  end
582
582
 
583
583
  def test_unsupported_part
584
- assert_raises(ArgumentError) do
584
+ assert_raises(InvalidDataException) do
585
585
  parse(
586
586
  'FREQ=DAILY;BYWODAN=1',
587
587
  '2014-08-02 00:15:00',