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
Search Repo:
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
test that posting a comment clears the comment feed caches

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2269 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sun Sep 24 23:13:33 -0700 2006
commit  c7ab20fea87d25476c02707fbc01e51c98a23c65
tree    cd9c8dab72d07f0ca1ebc17a2fec6a801e0dca13
parent  48a8d52db2d7551ace365f251f28ec7624bc8b0e
...
22
23
24
25
 
26
27
28
29
...
22
23
24
 
25
26
27
28
29
0
@@ -22,7 +22,7 @@ class CommentSweeper < ActionController::Caching::Sweeper
0
   
0
   protected
0
     def expire_cache_for(comment)
0
- pages = CachedPage.find_by_reference(comment.article)
0
+ pages = CachedPage.find_by_references(comment, comment.article)
0
       expire_cached_pages "Expired pages referenced by #{comment.class} ##{comment.id}", *pages
0
     end
0
 end
0
\ No newline at end of file
...
31
32
33
 
34
35
36
37
38
39
 
40
41
...
31
32
33
34
35
36
37
38
39
40
41
42
43
0
@@ -31,11 +31,13 @@ class FeedController < ApplicationController
0
       @comments = @section.find_comments(:limit => 15, :include => :article)
0
       cached_references << @section
0
       self.cached_references += @comments
0
+ self.cached_references += @comments.collect(&:article_referenced_cache_key)
0
     end
0
     
0
     def comment_feed_for_site
0
       @comments = site.comments.find(:all, :limit => 15, :include => :article)
0
       cached_references << @section
0
       self.cached_references += @comments
0
+ self.cached_references += @comments.collect(&:article_referenced_cache_key)
0
     end
0
 end
...
33
34
35
36
 
37
38
39
...
33
34
35
 
36
37
38
39
0
@@ -33,7 +33,7 @@ class CachedPage < ActiveRecord::Base
0
     #
0
     def find_by_reference_keys(*array_of_keys)
0
       with_current_scope do
0
- find :all, :conditions => [array_of_keys.collect { |r| "#{connection.quote_column_name('references')} LIKE ?" } * ' OR ', array_of_keys.collect { |r| "%[#{[r.last, r.first] * ':'}]%" }]
0
+ find :all, :conditions => ["(#{array_of_keys.collect { |r| "#{connection.quote_column_name('references')} LIKE ?" } * ' OR '})", *array_of_keys.collect { |r| "%[#{[r.last, r.first] * ':'}]%" }]
0
       end
0
     end
0
 
...
42
43
44
 
 
 
 
45
46
47
...
42
43
44
45
46
47
48
49
50
51
0
@@ -42,6 +42,10 @@ class Comment < Content
0
     end
0
   end
0
 
0
+ def article_referenced_cache_key
0
+ "[#{article_id}:Article]"
0
+ end
0
+
0
   protected
0
     def snag_article_attributes
0
       self.attributes = { :site => article.site, :filter => article.site.filter, :title => article.title, :published_at => article.published_at, :permalink => article.permalink }
...
116
117
118
119
120
121
 
 
 
 
 
 
 
122
123
124
...
116
117
118
 
119
 
120
121
122
123
124
125
126
127
128
129
0
@@ -116,9 +116,14 @@ class CachingTest < ActionController::IntegrationTest
0
     assert_caches_page contents(:welcome).full_permalink do
0
       visitor.read contents(:welcome)
0
     end
0
- visitor.comment_on contents(:welcome), :author => 'approved bob', :body => 'what a wonderful post.'
0
     
0
- assert_not_cached contents(:welcome).full_permalink
0
+ assert_caches_page "/feed/comments.xml", "/feed/all_comments.xml" do |urls|
0
+ urls.each { |u| visitor.get u }
0
+ end
0
+
0
+ assert_expires_pages contents(:welcome).full_permalink, "/feed/comments.xml", "/feed/all_comments.xml" do
0
+ visitor.comment_on contents(:welcome), :author => 'approved bob', :body => 'what a wonderful post.'
0
+ end
0
   end
0
 
0
   def test_should_expire_cache_when_comment_is_approved
...
10
11
12
13
 
14
15
16
17
18
 
19
20
21
...
10
11
12
 
13
14
15
16
17
 
18
19
20
21
0
@@ -10,12 +10,12 @@ module Mephisto # :nodoc:
0
       end
0
 
0
       def assert_caches_pages(*urls)
0
- yield if block_given?
0
+ yield(urls) if block_given?
0
         urls.map { |url| assert_cached url }
0
       end
0
 
0
       def assert_expires_pages(*urls)
0
- yield if block_given?
0
+ yield(urls) if block_given?
0
         urls.map { |url| assert_not_cached url }
0
       end
0
 

Comments

    No one has commented yet.