Commit 0f2dfa79ecdeb17d4a2b8972393e9026d225fb24
Committed by
Antonio Terceiro
1 parent
26b0349f
Exists in
master
and in
29 other branches
Expiring article cache after a comment
ActionItem1301
Showing
2 changed files
with
11 additions
and
0 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
@@ -97,6 +97,7 @@ class ContentViewerController < ApplicationController | @@ -97,6 +97,7 @@ class ContentViewerController < ApplicationController | ||
97 | @comment.author = user if logged_in? | 97 | @comment.author = user if logged_in? |
98 | @comment.article = @page | 98 | @comment.article = @page |
99 | if @comment.save | 99 | if @comment.save |
100 | + @page.touch | ||
100 | @comment = nil # clear the comment form | 101 | @comment = nil # clear the comment form |
101 | else | 102 | else |
102 | @form_div = 'opened' | 103 | @form_div = 'opened' |
test/functional/content_viewer_controller_test.rb
@@ -873,4 +873,14 @@ class ContentViewerControllerTest < Test::Unit::TestCase | @@ -873,4 +873,14 @@ class ContentViewerControllerTest < Test::Unit::TestCase | ||
873 | assert_tag :tag => 'a', :content => 'New article' | 873 | assert_tag :tag => 'a', :content => 'New article' |
874 | end | 874 | end |
875 | 875 | ||
876 | + should 'touch article after adding a comment' do | ||
877 | + yesterday = Time.now.yesterday | ||
878 | + Article.record_timestamps = false | ||
879 | + page = profile.articles.create(:name => 'myarticle', :body => 'the body of the text', :created_at => yesterday, :updated_at => yesterday) | ||
880 | + Article.record_timestamps = true | ||
881 | + | ||
882 | + login_as('ze') | ||
883 | + post :view_page, :profile => profile.identifier, :page => [ 'myarticle' ], :comment => { :title => 'crap!', :body => 'I think that this article is crap' } | ||
884 | + assert_not_equal yesterday, assigns(:page).updated_at | ||
885 | + end | ||
876 | end | 886 | end |