summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/events.yml3
-rw-r--r--test/fixtures/occurrences.yml1
-rw-r--r--test/functional/events_controller_test.rb45
-rw-r--r--test/functional/occurrences_controller_test.rb45
-rw-r--r--test/unit/event_test.rb119
-rw-r--r--test/unit/helpers/events_helper_test.rb4
-rw-r--r--test/unit/helpers/occurrences_helper_test.rb4
-rw-r--r--test/unit/occurrence_test.rb8
8 files changed, 229 insertions, 0 deletions
diff --git a/test/fixtures/events.yml b/test/fixtures/events.yml
new file mode 100644
index 0000000..bd73671
--- /dev/null
+++ b/test/fixtures/events.yml
@@ -0,0 +1,3 @@
1# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
3
diff --git a/test/fixtures/occurrences.yml b/test/fixtures/occurrences.yml
new file mode 100644
index 0000000..a56c164
--- /dev/null
+++ b/test/fixtures/occurrences.yml
@@ -0,0 +1 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
diff --git a/test/functional/events_controller_test.rb b/test/functional/events_controller_test.rb
new file mode 100644
index 0000000..5698c7b
--- /dev/null
+++ b/test/functional/events_controller_test.rb
@@ -0,0 +1,45 @@
1require 'test_helper'
2
3class EventsControllerTest < ActionController::TestCase
4 # test "should get index" do
5 # get :index
6 # assert_response :success
7 # assert_not_nil assigns(:events)
8 # end
9 #
10 # test "should get new" do
11 # get :new
12 # assert_response :success
13 # end
14 #
15 # test "should create event" do
16 # assert_difference('Event.count') do
17 # post :create, :event => { }
18 # end
19 #
20 # assert_redirected_to event_path(assigns(:event))
21 # end
22 #
23 # test "should show event" do
24 # get :show, :id => events(:one).to_param
25 # assert_response :success
26 # end
27 #
28 # test "should get edit" do
29 # get :edit, :id => events(:one).to_param
30 # assert_response :success
31 # end
32 #
33 # test "should update event" do
34 # put :update, :id => events(:one).to_param, :event => { }
35 # assert_redirected_to event_path(assigns(:event))
36 # end
37 #
38 # test "should destroy event" do
39 # assert_difference('Event.count', -1) do
40 # delete :destroy, :id => events(:one).to_param
41 # end
42 #
43 # assert_redirected_to events_path
44 # end
45end
diff --git a/test/functional/occurrences_controller_test.rb b/test/functional/occurrences_controller_test.rb
new file mode 100644
index 0000000..0b00e0e
--- /dev/null
+++ b/test/functional/occurrences_controller_test.rb
@@ -0,0 +1,45 @@
1require 'test_helper'
2
3class OccurrencesControllerTest < ActionController::TestCase
4 # test "should get index" do
5 # get :index
6 # assert_response :success
7 # assert_not_nil assigns(:occurrences)
8 # end
9 #
10 # test "should get new" do
11 # get :new
12 # assert_response :success
13 # end
14 #
15 # test "should create occurrence" do
16 # assert_difference('Occurrence.count') do
17 # post :create, :occurrence => { }
18 # end
19 #
20 # assert_redirected_to occurrence_path(assigns(:occurrence))
21 # end
22 #
23 # test "should show occurrence" do
24 # get :show, :id => occurrences(:one).to_param
25 # assert_response :success
26 # end
27 #
28 # test "should get edit" do
29 # get :edit, :id => occurrences(:one).to_param
30 # assert_response :success
31 # end
32 #
33 # test "should update occurrence" do
34 # put :update, :id => occurrences(:one).to_param, :occurrence => { }
35 # assert_redirected_to occurrence_path(assigns(:occurrence))
36 # end
37 #
38 # test "should destroy occurrence" do
39 # assert_difference('Occurrence.count', -1) do
40 # delete :destroy, :id => occurrences(:one).to_param
41 # end
42 #
43 # assert_redirected_to occurrences_path
44 # end
45end
diff --git a/test/unit/event_test.rb b/test/unit/event_test.rb
new file mode 100644
index 0000000..8d51b1a
--- /dev/null
+++ b/test/unit/event_test.rb
@@ -0,0 +1,119 @@
1require 'test_helper'
2
3class EventTest < ActiveSupport::TestCase
4
5 def setup
6 Page.delete_all
7 @cal_node = Node.create :slug => "calendar"
8 @cal_node.move_to_child_of Node.root
9 @draft = @cal_node.find_or_create_draft User.first
10 @draft.title = "99C3"
11 @draft.abstract = "The 99th Chaos Comunication Congress"
12 @draft.body = "Its totally freakin awesome"
13 @draft.save
14 @cal_node.publish_draft!
15 @cal_node.head.reload
16 end
17
18 test 'verfy setup data' do
19 assert_not_nil @cal_node
20 assert_not_nil @cal_node.head
21 end
22
23 test 'creating an event with malformed rrule raises exception' do
24 assert_raise(ArgumentError) do
25 Event.create!(
26 :start_time => "2009-01-01T15:23:42".to_time,
27 :end_time => "2009-01-01T20:05:23".to_time,
28 :url => "http://events.ccc.de/congress/2082",
29 :latitude => 52.525308,
30 :longitude => 13.378944,
31 :rrule => "FOOBAR",
32 :allday => false,
33 :custom_rrule => false,
34 :node_id => @cal_node.id
35 )
36 end
37 end
38
39 test 'create day event for node with one occurrence' do
40 assert_not_nil event = Event.create!(
41 :start_time => "2009-01-01T15:23:42".to_time,
42 :end_time => "2009-01-01T20:05:23".to_time,
43 :url => "http://events.ccc.de/congress/2082",
44 :latitude => 52.525308,
45 :longitude => 13.378944,
46 :rrule => nil,
47 :allday => false,
48 :custom_rrule => false,
49 :node_id => @cal_node.id
50 )
51
52 assert_equal 1, Occurrence.count
53 assert_equal event.start_time, Occurrence.first.start_time
54 assert_equal event.end_time, Occurrence.first.end_time
55 assert_equal @cal_node.head.title, Occurrence.first.summary
56 end
57
58 test 'create day event with weekly reoccurrence and checking data' do
59 assert_not_nil event = Event.create!(
60 :start_time => "2009-01-01T15:23:42".to_time,
61 :end_time => "2009-01-01T20:05:23".to_time,
62 :url => "http://events.ccc.de/congress/2082",
63 :latitude => 52.525308,
64 :longitude => 13.378944,
65 :rrule => "FREQ=WEEKLY;INTERVAL=1",
66 :allday => false,
67 :custom_rrule => false,
68 :node_id => @cal_node.id
69 )
70
71 assert_not_nil scoped_occurrences = event.occurrences_in_range(
72 "2009-01-01".to_time, "2009-12-31".to_time
73 )
74
75 assert_equal 52, scoped_occurrences.length
76
77 assert_equal "2009-12-24T15:23:42".to_time, scoped_occurrences[51].start_time
78 assert_equal "2009-12-24T20:05:23".to_time, scoped_occurrences[51].end_time
79 assert_equal "99C3", scoped_occurrences[51].summary
80 assert_equal @cal_node.event, scoped_occurrences[51].event
81 assert_equal @cal_node, scoped_occurrences[51].node
82
83 assert_equal "2009-03-19T15:23:42".to_time, scoped_occurrences[11].start_time
84 assert_equal "2009-03-19T20:05:23".to_time, scoped_occurrences[11].end_time
85 assert_equal "99C3", scoped_occurrences[11].summary
86 assert_equal @cal_node.event, scoped_occurrences[11].event
87 assert_equal @cal_node, scoped_occurrences[11].node
88
89 assert_equal "2009-01-01T15:23:42".to_time, scoped_occurrences[0].start_time
90 assert_equal "2009-01-01T20:05:23".to_time, scoped_occurrences[0].end_time
91 assert_equal "99C3", scoped_occurrences[0].summary
92 assert_equal @cal_node.event, scoped_occurrences[11].event
93 assert_equal @cal_node, scoped_occurrences[11].node
94 end
95
96 test 'create chaosradio event with custom rrule and interval' do
97 assert_not_nil event = Event.create!(
98 :start_time => "2009-01-28T21:00:00".to_time,
99 :end_time => "2009-01-28T23:00:00".to_time,
100 :url => "http://chaosradio.ccc.de",
101 :latitude => 52.525308,
102 :longitude => 13.378944,
103 :rrule => "FREQ=MONTHLY;INTERVAL=1;BYDAY=-1WE",
104 :allday => false,
105 :custom_rrule => true,
106 :node_id => @cal_node.id
107 )
108
109 assert_not_nil scoped_occurrences = event.occurrences_in_range(
110 "2009-01-01".to_time, "2009-12-31".to_time
111 )
112
113 assert_equal 12, scoped_occurrences.length
114
115 expected_days = [28, 25, 25, 29, 27, 24, 29, 26, 30, 28, 25, 30]
116 chaosradio_days = scoped_occurrences.map {|x| x.start_time.day}
117 assert_equal expected_days, chaosradio_days
118 end
119end \ No newline at end of file
diff --git a/test/unit/helpers/events_helper_test.rb b/test/unit/helpers/events_helper_test.rb
new file mode 100644
index 0000000..2e7567e
--- /dev/null
+++ b/test/unit/helpers/events_helper_test.rb
@@ -0,0 +1,4 @@
1require 'test_helper'
2
3class EventsHelperTest < ActionView::TestCase
4end
diff --git a/test/unit/helpers/occurrences_helper_test.rb b/test/unit/helpers/occurrences_helper_test.rb
new file mode 100644
index 0000000..0692926
--- /dev/null
+++ b/test/unit/helpers/occurrences_helper_test.rb
@@ -0,0 +1,4 @@
1require 'test_helper'
2
3class OccurrencesHelperTest < ActionView::TestCase
4end
diff --git a/test/unit/occurrence_test.rb b/test/unit/occurrence_test.rb
new file mode 100644
index 0000000..91a78ec
--- /dev/null
+++ b/test/unit/occurrence_test.rb
@@ -0,0 +1,8 @@
1require 'test_helper'
2
3class OccurrenceTest < ActiveSupport::TestCase
4 # Replace this with your real tests.
5 test "the truth" do
6 assert true
7 end
8end