Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki

This commit is contained in:
Jacques Distler 2009-08-04 00:08:01 -05:00
commit 96defb0945
4 changed files with 16 additions and 1 deletions

View file

@ -6,6 +6,12 @@ class RevisionSweeper < ActionController::Caching::Sweeper
observe Revision, Page observe Revision, Page
def before_save(record)
if record.is_a?(Revision)
expire_cached_revisions(record.page)
end
end
def after_save(record) def after_save(record)
if record.is_a?(Revision) if record.is_a?(Revision)
expire_caches(record.page) expire_caches(record.page)

View file

@ -250,8 +250,12 @@ class WikiController < ApplicationController
def rollback def rollback
get_page_and_revision get_page_and_revision
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) @page.lock(Time.now, @author)
end end
end
def save def save
render(:status => 404, :text => 'Undefined page name', :layout => 'error') and return if @page_name.nil? or not @page_name.is_utf8? render(:status => 404, :text => 'Undefined page name', :layout => 'error') and return if @page_name.nil? or not @page_name.is_utf8?

View file

@ -427,11 +427,15 @@ class WikiControllerTest < ActionController::TestCase
def test_rollback def test_rollback
# rollback shows a form where a revision can be edited. # rollback shows a form where a revision can be edited.
# its assigns the same as or revision # 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' r = process 'rollback', 'web' => 'wiki1', 'id' => 'HomePage', 'rev' => '1'
assert_response(:success) assert_response(:success)
assert_equal @home, r.template_objects['page'] assert_equal @home, r.template_objects['page']
assert_equal @home.revisions[0], r.template_objects['revision'] assert_equal @home.revisions[0], r.template_objects['revision']
home_page = Page.find(@home.id)
assert home_page.locked?(Time.now)
end end
def test_atom_with_content def test_atom_with_content

View file

@ -543,6 +543,7 @@ END_THM
Revision.create(:page => @page, :content => 'What a red and lovely morning today', Revision.create(:page => @page, :content => 'What a red and lovely morning today',
:author => Author.new('DavidHeinemeierHansson'), :revised_at => Time.now) :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" + 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 "</ins> and lovely morning<ins class='diffins'> today</ins></span></p>", test_renderer(@page.revisions.last).display_diff
end end