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 !
expire cache if new comment is approved

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1555 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Mon Aug 07 23:15:07 -0700 2006
commit  1a584599ab9c9be14a4ef28e19e184a363738cd4
tree    bded9dcf28faa8e7c47c49e6a8136945848223ae
parent  76055a6b31eea7d21b57c572fae491dafd6ea935
...
2
3
4
5
6
 
 
 
 
 
 
 
 
7
8
9
...
2
3
4
 
 
5
6
7
8
9
10
11
12
13
14
15
0
@@ -2,8 +2,14 @@ class CommentSweeper < ActionController::Caching::Sweeper
0
   include Mephisto::SweeperMethods
0
   observe Comment
0
 
0
- def after_update(record)
0
- return if controller.nil?
0
+ # only sweep updates, not creations
0
+ # tagged 'lame hack'
0
+ def before_save(record)
0
+ @new = record.new_record?
0
+ end
0
+
0
+ def after_save(record)
0
+ return if controller.nil? || (@new && !record.approved?)
0
     expire_overview_feed!
0
     pages = CachedPage.find_by_reference(record.article)
0
     expire_cached_pages "Expired pages referenced by #{record.class} ##{record.id}", *pages
...
98
99
100
 
 
 
 
 
 
 
 
 
 
 
101
102
103
...
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
0
@@ -98,6 +98,17 @@ class CachingTest < ActionController::IntegrationTest
0
     assert_cached contents(:welcome).full_permalink
0
   end
0
 
0
+ def test_should_expire_cache_on_new_comment_if_approved
0
+ visitor = visit
0
+ assert_caches_page contents(:welcome).full_permalink do
0
+ visitor.read contents(:welcome)
0
+ end
0
+
0
+ visitor.comment_on contents(:welcome), :author => 'approved bob', :body => 'what a wonderful post.'
0
+
0
+ assert_not_cached contents(:welcome).full_permalink
0
+ end
0
+
0
   def test_should_expire_cache_when_comment_is_approved
0
     visitor = visit
0
     assert_caches_page contents(:welcome).full_permalink do

Comments

    No one has commented yet.