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 !
fix bug with comment_age=0

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1577 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sat Aug 12 07:21:21 -0700 2006
commit  98f18b40b99e04386752bbf4df5a17cde30be1c1
tree    716f1ad2a9229347bf1ef149c8c2c9cc2684d7ea
parent  198b9cd4ad3f20034ada3ccd30695e7a51cf4b76
...
111
112
113
114
 
 
 
 
 
115
116
117
...
111
112
113
 
114
115
116
117
118
119
120
121
0
@@ -111,7 +111,11 @@ class Article < Content
0
   end
0
 
0
   def accept_comments?
0
- status == :published && (comment_age.to_i > -1) && (published_at + comment_age.to_i.days > Time.now.utc)
0
+ status == :published && (comment_age > -1) && (comment_age == 0 || comments_expired_at > Time.now.utc)
0
+ end
0
+
0
+ def comments_expired_at
0
+ published_at + comment_age.days
0
   end
0
 
0
   # leave out macro_filter, that is turned on/off with parse_macros?
...
66
67
68
69
 
 
 
 
 
 
70
71
72
 
73
74
75
76
77
 
 
 
 
78
79
80
...
114
115
116
 
 
 
 
 
 
117
...
66
67
68
 
69
70
71
72
73
74
75
 
 
76
77
78
79
80
81
82
83
84
85
86
87
88
...
122
123
124
125
126
127
128
129
130
131
0
@@ -66,15 +66,23 @@ class ArticleTest < Test::Unit::TestCase
0
     contents(:welcome).body_html = 'nope'
0
     assert !contents(:welcome).save_version?
0
   end
0
-
0
+
0
+ def test_comment_expiration_date
0
+ a = create_fake_article
0
+ assert_equal 5.days.from_now.utc.to_i, a.comments_expired_at.to_i
0
+ end
0
+
0
   def test_comment_expiry
0
- a = Article.new :comment_age => 10, :published_at => 5.days.from_now.utc
0
- def a.new_record?() false ; end
0
+ a = create_fake_article(5.days.from_now)
0
     assert !a.accept_comments?
0
     a.published_at = 5.days.ago.utc
0
     assert a.accept_comments?
0
     a.comment_age = 2
0
     assert !a.accept_comments?
0
+ a.published_at = 5.years.ago.utc
0
+ assert !a.accept_comments?
0
+ a.comment_age = 0
0
+ assert a.accept_comments?
0
   end
0
 
0
   def test_empty_body
0
@@ -114,4 +122,10 @@ class ArticleTest < Test::Unit::TestCase
0
     def create_article(options = {})
0
       Article.create options.reverse_merge(:user_id => 1, :site_id => 1, :title => 'foo')
0
     end
0
+
0
+ def create_fake_article(time = 5.days.ago)
0
+ returning Article.new(:comment_age => 10, :published_at => time.utc) do |a|
0
+ def a.new_record?() false ; end
0
+ end
0
+ end
0
 end

Comments

    No one has commented yet.