Fix Two bugs from Toby Bartels
1. Ensure that "rollback" respects locked pages. 2. Expire revisions of an edited page. Use a before_save hook to deal with the situation where a page's name has been changed.
This commit is contained in:
parent
0e0f666fb4
commit
329fafafce
4 changed files with 16 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 "<p><span> What a<del class='diffmod'> blue</del><ins class='diffmod'> red" +
|
||||
"</ins> and lovely morning<ins class='diffins'> today</ins></span></p>", test_renderer(@page.revisions.last).display_diff
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue