public
Description: Canberra Ruby Crew Site #crc
Homepage: http://canberraruby.com
Clone URL: git://github.com/artpop/crc_site.git
move schlick's next meeting helper into the FrontHelper
timriley (author)
Thu Oct 16 04:19:12 -0700 2008
commit  8a2f461d9ae2b227e3a98272cc7b7d93aa34db6b
tree    46dd20f1378311770cad1a3cd910fd6dfddbfd29
parent  78c38212d8e73ebd7e8b3b2f13b4c70f554837b1
...
1
 
 
 
 
 
 
 
 
 
 
2
...
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1,2 +1,12 @@
0
 module FrontHelper
0
+  # TODO: should be made customisable
0
+  MEETING_WDAY = 3        # Wednesday
0
+  
0
+  # returns the date for the next meeting
0
+  def next_meeting_date
0
+    last_day_of_month = Date.today.end_of_month
0
+    total = last_day_of_month.wday + MEETING_WDAY + 1
0
+    total -= 7 if total >= 7
0
+    return last_day_of_month - total.days
0
+  end  
0
 end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
1
2
 
 
 
 
 
 
 
 
 
 
 
3
0
@@ -1,14 +1,3 @@
0
 module PageHelper
0
   
0
-  # TODO: should be made customisable
0
-  MEETING_WDAY = 3        # Wednesday
0
-  
0
-  # returns the date for the next meeting
0
-  def next_meeting_date
0
-    last_day_of_month = Date.today.end_of_month
0
-    total = last_day_of_month.wday + MEETING_WDAY + 1
0
-    total -= 7 if total >= 7
0
-    return last_day_of_month - total.days
0
-  end
0
-  
0
 end
...
11
12
13
14
15
16
17
18
19
20
21
...
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
87
88
89
90
91
92
93
94
95
96
97
98
99
...
11
12
13
 
 
 
 
 
14
15
16
...
57
58
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
61
62
...
67
68
69
 
 
 
 
 
 
 
 
 
70
0
@@ -11,11 +11,6 @@
0
 
0
 ActiveRecord::Schema.define(:version => 20081015120059) do
0
 
0
-  create_table "attendance", :id => false, :force => true do |t|
0
-    t.integer "meeting_id", :limit => 11
0
-    t.integer "person_id",  :limit => 11
0
-  end
0
-
0
   create_table "bj_config", :primary_key => "bj_config_id", :force => true do |t|
0
     t.text "hostname"
0
     t.text "key"
0
@@ -62,21 +57,6 @@ ActiveRecord::Schema.define(:version => 20081015120059) do
0
     t.integer  "exit_status",    :limit => 11
0
   end
0
 
0
-  create_table "comments", :force => true do |t|
0
-    t.text     "note"
0
-    t.datetime "created_at"
0
-    t.datetime "updated_at"
0
-    t.integer  "person_id",  :limit => 11
0
-    t.integer  "topic_id",   :limit => 11
0
-  end
0
-
0
-  create_table "meetings", :force => true do |t|
0
-    t.datetime "date"
0
-    t.datetime "created_at"
0
-    t.datetime "updated_at"
0
-    t.string   "venue"
0
-  end
0
-
0
   create_table "people", :force => true do |t|
0
     t.string   "username"
0
     t.string   "name"
0
@@ -87,13 +67,4 @@ ActiveRecord::Schema.define(:version => 20081015120059) do
0
     t.string   "twitter_user"
0
   end
0
 
0
-  create_table "topics", :force => true do |t|
0
-    t.string   "title"
0
-    t.text     "description"
0
-    t.string   "link"
0
-    t.datetime "created_at"
0
-    t.datetime "updated_at"
0
-    t.integer  "meeting_id",  :limit => 11
0
-  end
0
-
0
 end
...
1
2
3
 
4
5
6
7
8
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
...
1
2
3
4
5
 
 
 
 
 
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
0
@@ -1,11 +1,79 @@
0
 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
0
 
0
 describe FrontHelper do
0
+  include FrontHelper
0
   
0
-  #Delete this example and add some real ones or delete this file
0
-  it "should be included in the object returned by #helper" do
0
-    included_modules = (class << helper; self; end).send :included_modules
0
-    included_modules.should include(FrontHelper)
0
-  end
0
+  # TODO: change the tests so that it is not tied to the particular day of the week
0
+  describe "next_meeting_date (Wednesday)" do
0
+    
0
+    it "should return last Wednesday for month ending on a Wednesday" do
0
+      mock_today = Date.new(2008,12,1)
0
+      last_wednesday = mock_today.end_of_month
0
+      1.upto(31) { |d|
0
+        Date.stub!(:today).and_return(mock_today)
0
+        next_meeting_date.should eql(last_wednesday)      
0
+        mock_today += 1.day
0
+      }
0
+    end
0
+
0
+    it "should return last Wednesday for month ending on a Thursday" do
0
+      mock_today = Date.new(2008,7,1)
0
+      last_wednesday = mock_today.end_of_month - 1.day
0
+      1.upto(31) { |d|
0
+        Date.stub!(:today).and_return(mock_today)
0
+        next_meeting_date.should eql(last_wednesday)      
0
+        mock_today += 1.day
0
+      }
0
+    end
0
+
0
+    it "should return last Wednesday for month ending on a Friday" do
0
+      mock_today = Date.new(2008,10,1)
0
+      last_wednesday = mock_today.end_of_month - 2.days
0
+      1.upto(31) { |d|
0
+        Date.stub!(:today).and_return(mock_today)
0
+        next_meeting_date.should eql(last_wednesday)      
0
+        mock_today += 1.day
0
+      }
0
+    end
0
 
0
+    it "should return last Wednesday for month ending on a Saturday" do
0
+      mock_today = Date.new(2008,5,1)
0
+      last_wednesday = mock_today.end_of_month - 3.days
0
+      1.upto(30) { |d|
0
+        Date.stub!(:today).and_return(mock_today)
0
+        next_meeting_date.should eql(last_wednesday)      
0
+        mock_today += 1.day
0
+      }
0
+    end
0
+
0
+    it "should return last Wednesday for month ending on a Sunday" do
0
+      mock_today = Date.new(2008,8,1)
0
+      last_wednesday = mock_today.end_of_month - 4.days
0
+      1.upto(31) { |d|
0
+        Date.stub!(:today).and_return(mock_today)
0
+        next_meeting_date.should eql(last_wednesday)      
0
+        mock_today += 1.day
0
+      }
0
+    end
0
+       
0
+    it "should return last Wednesday for month ending on a Monday" do
0
+      mock_today = Date.new(2008,6,1)
0
+      last_wednesday = mock_today.end_of_month - 5.days
0
+      1.upto(30) { |d|
0
+        Date.stub!(:today).and_return(mock_today)
0
+        next_meeting_date.should eql(last_wednesday)      
0
+        mock_today += 1.day
0
+      }
0
+    end
0
+
0
+    it "should return last Wednesday for month ending on a Tuesday" do
0
+      mock_today = Date.new(2008,9,1)
0
+      last_wednesday = mock_today.end_of_month - 6.days
0
+      1.upto(30) { |d|      
0
+        Date.stub!(:today).and_return(mock_today)
0
+        next_meeting_date.should eql(last_wednesday)
0
+        mock_today += 1.day     
0
+      }
0
+    end          
0
+  end
0
 end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
...
1
2
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
5
0
@@ -1,81 +1,5 @@
0
 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
0
 
0
 describe PageHelper do
0
-  include PageHelper
0
-  
0
-  # TODO: change the tests so that it is not tied to the particular day of the week
0
-  describe "next_meeting_date (Wednesday)" do
0
-    
0
-    it "should return last Wednesday for month ending on a Wednesday" do
0
-      mock_today = Date.new(2008,12,1)
0
-      last_wednesday = mock_today.end_of_month
0
-      1.upto(31) { |d|
0
-        Date.stub!(:today).and_return(mock_today)
0
-        next_meeting_date.should eql(last_wednesday)      
0
-        mock_today += 1.day
0
-      }
0
-    end
0
-
0
-    it "should return last Wednesday for month ending on a Thursday" do
0
-      mock_today = Date.new(2008,7,1)
0
-      last_wednesday = mock_today.end_of_month - 1.day
0
-      1.upto(31) { |d|
0
-        Date.stub!(:today).and_return(mock_today)
0
-        next_meeting_date.should eql(last_wednesday)      
0
-        mock_today += 1.day
0
-      }
0
-    end
0
-
0
-    it "should return last Wednesday for month ending on a Friday" do
0
-      mock_today = Date.new(2008,10,1)
0
-      last_wednesday = mock_today.end_of_month - 2.days
0
-      1.upto(31) { |d|
0
-        Date.stub!(:today).and_return(mock_today)
0
-        next_meeting_date.should eql(last_wednesday)      
0
-        mock_today += 1.day
0
-      }
0
-    end
0
-
0
-    it "should return last Wednesday for month ending on a Saturday" do
0
-      mock_today = Date.new(2008,5,1)
0
-      last_wednesday = mock_today.end_of_month - 3.days
0
-      1.upto(30) { |d|
0
-        Date.stub!(:today).and_return(mock_today)
0
-        next_meeting_date.should eql(last_wednesday)      
0
-        mock_today += 1.day
0
-      }
0
-    end
0
-
0
-    it "should return last Wednesday for month ending on a Sunday" do
0
-      mock_today = Date.new(2008,8,1)
0
-      last_wednesday = mock_today.end_of_month - 4.days
0
-      1.upto(31) { |d|
0
-        Date.stub!(:today).and_return(mock_today)
0
-        next_meeting_date.should eql(last_wednesday)      
0
-        mock_today += 1.day
0
-      }
0
-    end
0
-       
0
-    it "should return last Wednesday for month ending on a Monday" do
0
-      mock_today = Date.new(2008,6,1)
0
-      last_wednesday = mock_today.end_of_month - 5.days
0
-      1.upto(30) { |d|
0
-        Date.stub!(:today).and_return(mock_today)
0
-        next_meeting_date.should eql(last_wednesday)      
0
-        mock_today += 1.day
0
-      }
0
-    end
0
-
0
-    it "should return last Wednesday for month ending on a Tuesday" do
0
-      mock_today = Date.new(2008,9,1)
0
-      last_wednesday = mock_today.end_of_month - 6.days
0
-      1.upto(30) { |d|      
0
-        Date.stub!(:today).and_return(mock_today)
0
-        next_meeting_date.should eql(last_wednesday)
0
-        mock_today += 1.day     
0
-      }
0
-    end
0
-          
0
-  end
0
 
0
 end

Comments