public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
change time delta so the end date is one second earlier, so a search 
doesn't include the articles on the next month.  [Jon Leighton]

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2371 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sun Oct 15 12:38:35 -0700 2006
commit  9a7b1d2b86bd5cefa8bcc7c33e6b99305f94133c
tree    32786a87c244a84d10c1d20dde85b6829d21446c
parent  ba574f63e7f06f0b90440359ba78e6ff3cecc6db
...
1
2
 
 
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
10
11
0
@@ -1,5 +1,11 @@
0
 * SVN *
0
 
0
+* change time delta so the end date is one second earlier, so a search doesn't include the articles on the next month. [Jon Leighton]
0
+
0
+* use precise time methods when calculating time deltas [Jon Leighton]
0
+
0
+* remove .svn dirs when copying default them [Cristi Balan]
0
+
0
 * Added linked_tag_list(article, separator). Use like linked_section_list.
0
 
0
 * Enhanced the theme preview slightly
...
109
110
111
112
 
113
114
115
...
109
110
111
 
112
113
114
115
0
@@ -109,7 +109,7 @@ class Time
0
       else
0
         from.advance :years => 1
0
       end
0
- return [from.midnight, to.midnight]
0
+ return [from.midnight, to.midnight-1]
0
   end
0
 end
0
 
...
152
153
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
156
...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
0
@@ -152,4 +152,56 @@ draft:
0
   updated_at: <%= 1.day.ago.utc.to_s(:db) %>
0
   comment_age: 30
0
   user_id: 1
0
+ type: Article
0
+at_beginning_of_month:
0
+ id: 12
0
+ site_id: 1
0
+ title: At beginning of the month
0
+ permalink: at-beginning-of-the-month
0
+ body: Lalala
0
+ body_html: Lalala
0
+ created_at: <%= date = Time.now.utc.beginning_of_month.advance(:months => -2).to_s(:db) %>
0
+ updated_at: <%= date %>
0
+ published_at: <%= date %>
0
+ comment_age: 30
0
+ user_id: 1
0
+ type: Article
0
+at_middle_of_month:
0
+ id: 13
0
+ site_id: 1
0
+ title: At middle of the month
0
+ permalink: at-middle-of-the-month
0
+ body: Lalala
0
+ body_html: Lalala
0
+ created_at: <%= date = Time.now.utc.beginning_of_month.advance(:months => -1, :days => -15).to_s(:db) %>
0
+ updated_at: <%= date %>
0
+ published_at: <%= date %>
0
+ comment_age: 30
0
+ user_id: 1
0
+ type: Article
0
+at_end_of_month:
0
+ id: 14
0
+ site_id: 1
0
+ title: At end of the month
0
+ permalink: at-end-of-the-month
0
+ body: Lalala
0
+ body_html: Lalala
0
+ created_at: <%= date = (Time.now.utc.beginning_of_month.advance(:months => -1) -1).to_s(:db) %>
0
+ updated_at: <%= date %>
0
+ published_at: <%= date %>
0
+ comment_age: 30
0
+ user_id: 1
0
+ type: Article
0
+at_beginning_of_next_month:
0
+ id: 15
0
+ site_id: 1
0
+ title: At beginning of next month
0
+ permalink: at-beginning-of-next-month
0
+ body: Lalala
0
+ body_html: Lalala
0
+ created_at: <%= date = Time.now.utc.beginning_of_month.advance(:months => -1).to_s(:db) %>
0
+ updated_at: <%= date %>
0
+ published_at: <%= date %>
0
+ comment_age: 30
0
+ user_id: 1
0
   type: Article
0
\ No newline at end of file
...
16
17
18
19
 
20
21
22
...
16
17
18
 
19
20
21
22
0
@@ -16,7 +16,7 @@ class Admin::ArticlesControllerPermissionsTest < Test::Unit::TestCase
0
 
0
   def test_should_show_articles
0
     get :index
0
- assert_equal 6, assigns(:articles).length
0
+ assert_equal 10, assigns(:articles).length
0
   end
0
 
0
   def test_should_show_new_article_form
...
28
29
30
31
 
32
33
34
35
36
 
37
38
39
...
28
29
30
 
31
32
33
34
35
 
36
37
38
39
0
@@ -28,12 +28,12 @@ class Admin::ArticlesControllerTest < Test::Unit::TestCase
0
   
0
   def test_should_show_articles
0
     get :index
0
- assert_equal 6, assigns(:articles).length
0
+ assert_equal 10, assigns(:articles).length
0
   end
0
   
0
   def test_should_show_articles_with_empty_seartest_should_show_checked_sectionsch
0
     get :index, :q => '', :filter => 'title', :section => '0'
0
- assert_equal 6, assigns(:articles).length
0
+ assert_equal 10, assigns(:articles).length
0
   end
0
 
0
   def test_should_search_article_titles
...
153
154
155
 
 
 
 
 
 
 
 
 
 
156
157
158
...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
0
@@ -153,6 +153,16 @@ class ArticleTest < Test::Unit::TestCase
0
     assert_equal contents(:welcome), sites(:first).articles.find_by_permalink(:year => contents(:welcome).year, :permalink => contents(:welcome).permalink)
0
   end
0
 
0
+ def test_should_find_all_in_month
0
+ two_months_ago = Time.now.utc.advance(:months => -2)
0
+ articles = Article.find_all_in_month(two_months_ago.year, two_months_ago.month)
0
+
0
+ assert_equal 3, articles.length
0
+ [:at_beginning_of_month, :at_end_of_month, :at_middle_of_month].each do |article|
0
+ assert articles.include?(contents(article))
0
+ end
0
+ end
0
+
0
   protected
0
     def create_article(options = {})
0
       Article.create options.reverse_merge(:user_id => 1, :site_id => 1, :title => 'foo')
...
32
33
34
35
 
 
36
37
38
...
32
33
34
 
35
36
37
38
39
0
@@ -32,7 +32,8 @@ context "Drop Filters" do
0
   end
0
 
0
   specify "should find latest articles by site" do
0
- assert_models_equal [contents(:welcome), contents(:about), contents(:site_map), contents(:another)], latest_articles(@site).collect(&:source)
0
+ assert_models_equal [contents(:welcome), contents(:about), contents(:site_map), contents(:another), contents(:at_beginning_of_next_month), contents(:at_end_of_month), contents(:at_middle_of_month), contents(:at_beginning_of_month)],
0
+ latest_articles(@site).collect(&:source)
0
     assert_models_equal [contents(:welcome), contents(:about)], latest_articles(@site, 2).collect(&:source)
0
   end
0
   
...
54
55
56
57
 
 
58
59
60
...
54
55
56
 
57
58
59
60
61
0
@@ -54,7 +54,8 @@ class SiteDropTest < Test::Unit::TestCase
0
   end
0
 
0
   def test_should_find_latest_articles
0
- assert_models_equal [contents(:welcome), contents(:about), contents(:site_map), contents(:another)], @site.latest_articles.collect(&:source)
0
+ assert_models_equal [contents(:welcome), contents(:about), contents(:site_map), contents(:another), contents(:at_beginning_of_next_month), contents(:at_end_of_month), contents(:at_middle_of_month), contents(:at_beginning_of_month)],
0
+ @site.latest_articles.collect(&:source)
0
     assert_models_equal [contents(:welcome), contents(:about)], @site.latest_articles(2).collect(&:source)
0
   end
0
 
...
2
3
4
5
 
6
7
8
9
10
11
 
 
 
12
13
14
15
 
16
17
...
2
3
4
 
5
6
7
8
 
 
 
9
10
11
12
13
14
 
15
16
17
0
@@ -2,16 +2,16 @@ require File.dirname(__FILE__) + '/../test_helper'
0
 
0
 class TimeTest < Test::Unit::TestCase
0
   def test_should_show_year_delta
0
- assert_equal [Time.local(2006, 1, 1), Time.local(2007,1,1)], Time.local(2006,7,1).to_delta(:year)
0
+ assert_equal [Time.local(2006, 1, 1), Time.local(2007,1,1)-1], Time.local(2006,7,1).to_delta(:year)
0
   end
0
 
0
   def test_should_show_month_delta
0
- assert_equal [Time.local(2006, 7, 1), Time.local(2006, 8, 1)], Time.local(2006, 7, 15).to_delta(:month)
0
- assert_equal [Time.local(2006, 11, 1), Time.local(2006, 12, 1)], Time.local(2006, 11, 1).to_delta(:month)
0
- assert_equal [Time.local(2006, 12, 1), Time.local(2007, 1, 1)], Time.local(2006, 12, 1).to_delta(:month)
0
+ assert_equal [Time.local(2006, 7, 1), Time.local(2006, 8, 1)-1], Time.local(2006, 7, 15).to_delta(:month)
0
+ assert_equal [Time.local(2006, 11, 1), Time.local(2006, 12, 1)-1], Time.local(2006, 11, 1).to_delta(:month)
0
+ assert_equal [Time.local(2006, 12, 1), Time.local(2007, 1, 1)-1], Time.local(2006, 12, 1).to_delta(:month)
0
   end
0
 
0
   def test_should_show_daily_delta
0
- assert_equal [Time.local(2006, 7, 15), Time.local(2006,7,16)], Time.local(2006,7,15).to_delta
0
+ assert_equal [Time.local(2006, 7, 15), Time.local(2006,7,16)-1], Time.local(2006,7,15).to_delta
0
   end
0
 end

Comments

    No one has commented yet.