summaryrefslogtreecommitdiff
path: root/test/unit/event_test.rb
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-03-10 23:51:03 +0100
committerhukl <contact@smyck.org>2009-03-10 23:51:03 +0100
commitc9fa047402fdc009319dca7b05455e8ce73eaee7 (patch)
tree232bcb793cb187a50ec38343f8f93a3901492c2f /test/unit/event_test.rb
parentd987886a9a94c6bad53ff7c7a241b85ea0b57de7 (diff)
remove event resource temporarily until its finalized
Diffstat (limited to 'test/unit/event_test.rb')
-rw-r--r--test/unit/event_test.rb77
1 files changed, 0 insertions, 77 deletions
diff --git a/test/unit/event_test.rb b/test/unit/event_test.rb
deleted file mode 100644
index c8ee335..0000000
--- a/test/unit/event_test.rb
+++ /dev/null
@@ -1,77 +0,0 @@
1require 'test_helper'
2
3class EventTest < ActiveSupport::TestCase
4
5 def setup
6 @cal = <<-EOT
7BEGIN:VCALENDAR
8VERSION:2.0
9PRODID:-//Ensemble Independent//vPim 0.658//EN
10CALSCALE:Gregorian
11BEGIN:VEVENT
12SUMMARY:Chaosradio
13DTSTART:20080505T220000
14LOCATION:FM 102,60 MHz
15URL:http://www.fritz.de/frequenzen
16RRULE:FREQ=MONTHLY;BYMONTH=1,2,3,4,5,6,7,8,9,10,11;BYDAY=-1WE;UNTIL=20091105T220000
17CREATED:20021020T220000
18DURATION:PT3H
19END:VEVENT
20END:VCALENDAR
21 EOT
22
23 @first_child = Node.find(2)
24 end
25
26 test 'saving serialized event' do
27 assert event = Event.create!( :serialized_event => @cal )
28 end
29
30 test 'parsing calendar data' do
31 event = Event.create!( :serialized_event => @cal )
32 assert calendar = ChaosCalendar.new
33 assert calendar.push( event.serialized_event, @first_child.id )
34 assert_equal 1, calendar.calendar.length
35 assert_equal "Chaosradio", calendar.calendar.to_a.first.first.summary
36 end
37
38 test 'checking occurrences logic' do
39 event = Event.create!( :serialized_event => @cal )
40 calendar = ChaosCalendar.new
41 calendar.push( event.serialized_event, @first_child.id )
42
43 all_occurrences = calendar.occurrences( "2009-03-22".to_datetime, "2010-01-10".to_datetime )
44 assert_equal 8, all_occurrences.length
45
46 assert_equal "2009-03-25".to_date, all_occurrences.first.dtstart.to_date
47 assert_equal "2009-10-28".to_date, all_occurrences.last.dtstart.to_date
48 end
49
50end
51
52__END__
53
54opt_days = 7
55
56calendar = ChaosCalendar.new
57
58
59calendar.push( cal, 25 )
60t0 = Time.today
61t1 = t0 + opt_days.days
62
63all_occurrences = calendar.occurrences( t0, t1 )
64
65all_occurrences.each do |o|
66 e = o.event
67 puts o.dtstart
68 puts "#{e.summary}:"
69
70 puts " description=#{e.description}" if e.description
71 puts " comment=#{e.comments.first}" if e.comments
72 puts " location=#{e.location}" if e.location
73 puts " status=#{e.status}" if e.status
74 puts " dtstart=#{e.dtstart}" if e.dtstart
75 puts " duration=#{Vpim::Duration.new(e.duration).to_s}" if e.duration
76end
77