public
Fork of halorgium/mephisto
Description: A refactored Mephisto that has multiple spam detection engines.
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/francois/mephisto.git
caching tests, dont cache GET requests to /path/to/article/comments or 
searches

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2227 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Wed Sep 20 18:48:14 -0700 2006
commit  b00a97637b0a8357dc55eef9b625da5eb023ef4e
tree    1e6355aa7df5039bc5da6859f87978c53f6c80c6
parent  e525dff691c364199af3c814623e3f1557cfd73e
...
36
37
38
 
39
40
41
...
97
98
99
 
100
101
102
...
36
37
38
39
40
41
42
...
98
99
100
101
102
103
104
0
@@ -36,6 +36,7 @@ class MephistoController < ApplicationController
0
     def dispatch_comments
0
       show_404 and return unless find_article
0
       if request.get? || params[:comment].blank?
0
+ @skip_caching = true
0
         redirect_to site.permalink_for(@article) and return
0
       end
0
     
0
@@ -97,6 +98,7 @@ class MephistoController < ApplicationController
0
                                           'next_page' => paged_search_url_for(@article_pages.current.next),
0
                                           'search_string' => params[:q],
0
                                           'search_count' => search_count)
0
+ @skip_caching = true
0
     end
0
     
0
     def dispatch_tags
...
3
4
5
 
6
7
8
...
24
25
26
27
 
 
 
 
 
28
29
30
...
3
4
5
6
7
8
9
...
25
26
27
 
28
29
30
31
32
33
34
35
0
@@ -3,6 +3,7 @@ module Mephisto # :nodoc:
0
     def self.included(base)
0
       base.helper_method :cached_references
0
       base.extend ClassMethods
0
+ base.alias_method_chain :caching_allowed, :skipping
0
       base.send :attr_writer, :cached_references
0
     end
0
 
0
@@ -24,7 +25,11 @@ module Mephisto # :nodoc:
0
       def cached_references
0
         @cached_references ||= []
0
       end
0
-
0
+
0
+ def caching_allowed_with_skipping
0
+ caching_allowed_without_skipping && !@skip_caching
0
+ end
0
+
0
       # Saves a CachedPage for the current request with the current references. This is called in an after filter if #caches_page_with_references
0
       # is used.
0
       def cache_page_with_references
...
80
81
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
84
85
...
250
251
252
 
 
 
 
 
 
 
 
 
253
254
255
...
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
...
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
0
@@ -80,6 +80,37 @@ class CachingTest < ActionController::IntegrationTest
0
     assert_cached contents(:welcome).full_permalink
0
   end
0
 
0
+ def test_should_not_cache_comment_post
0
+ visitor = visit
0
+ assert_expires_pages "#{contents(:welcome).full_permalink}/comments" do
0
+ visitor.comment_on contents(:welcome), :author => 'bob', :body => 'what a wonderful post.'
0
+ end
0
+ end
0
+
0
+ def test_should_not_cache_comment_post_on_article_with_closed_comments
0
+ visitor = visit
0
+ contents(:welcome).update_attribute :comment_age, -1
0
+ assert_expires_pages "#{contents(:welcome).full_permalink}/comments" do
0
+ visitor.comment_on contents(:welcome), :author => 'bob', :body => 'what a wonderful post.'
0
+ end
0
+ end
0
+
0
+ def test_should_not_cache_comment_post_on_article_with_invalid_comment
0
+ visitor = visit
0
+ assert_expires_pages "#{contents(:welcome).full_permalink}/comments" do
0
+ assert_no_difference Comment, :count do
0
+ visitor.comment_on contents(:welcome), {}
0
+ end
0
+ end
0
+ end
0
+
0
+ def test_should_not_cache_comments_page_on_get
0
+ visitor = visit
0
+ assert_expires_pages "#{contents(:welcome).full_permalink}/comments" do
0
+ visitor.get "#{contents(:welcome).full_permalink}/comments"
0
+ end
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
@@ -250,6 +281,15 @@ class CachingTest < ActionController::IntegrationTest
0
     end
0
   end
0
 
0
+ def test_should_not_cache_searches
0
+ visitor = visit
0
+ assert_expires_page "/search" do
0
+ visitor.get '/search'
0
+ visitor.get '/search', :q => 'foo'
0
+ visitor.post '/search', :q => 'foo'
0
+ end
0
+ end
0
+
0
   protected
0
     def visit_sections_and_feeds_with(visitor)
0
       assert_difference CachedPage, :count, 4 do

Comments

    No one has commented yet.