diff --git a/app/controllers/revision_sweeper.rb b/app/controllers/revision_sweeper.rb index f315fc06..6408133b 100644 --- a/app/controllers/revision_sweeper.rb +++ b/app/controllers/revision_sweeper.rb @@ -6,6 +6,12 @@ class RevisionSweeper < ActionController::Caching::Sweeper observe Revision, Page + def before_save(record) + if record.is_a?(Revision) + expire_cached_revisions(record.page) + end + end + def after_save(record) if record.is_a?(Revision) expire_caches(record.page) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index f7fb09e4..a1110e4b 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -250,7 +250,11 @@ class WikiController < ApplicationController def rollback get_page_and_revision - @page.lock(Time.now, @author) + if @page.locked?(Time.now) and not params['break_lock'] + redirect_to :web => @web_name, :action => 'locked', :id => @page_name + else + @page.lock(Time.now, @author) + end end def save diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index b337357b..dc226443 100755 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -427,11 +427,15 @@ class WikiControllerTest < ActionController::TestCase def test_rollback # rollback shows a form where a revision can be edited. # its assigns the same as or revision + home_page = Page.find(@home.id) + assert !home_page.locked?(Time.now) r = process 'rollback', 'web' => 'wiki1', 'id' => 'HomePage', 'rev' => '1' assert_response(:success) assert_equal @home, r.template_objects['page'] assert_equal @home.revisions[0], r.template_objects['revision'] + home_page = Page.find(@home.id) + assert home_page.locked?(Time.now) end def test_atom_with_content diff --git a/test/unit/page_renderer_test.rb b/test/unit/page_renderer_test.rb index 7cade33b..3e170fcb 100644 --- a/test/unit/page_renderer_test.rb +++ b/test/unit/page_renderer_test.rb @@ -543,6 +543,7 @@ END_THM Revision.create(:page => @page, :content => 'What a red and lovely morning today', :author => Author.new('DavidHeinemeierHansson'), :revised_at => Time.now) + @page.reload assert_equal "
What a blue red" +
" and lovely morning today