Dropped number from revision table. Also dropped timestamp. We will rely on autoincremented ID for sorting, and will for now store the time of last edit of the revision in revised_at. Later we will refactor content into a separate table (so as not to load the whole 300 kb of text and cached HTML every time we need page.revisions in code). Rake tests all pass, but watir tests indicate that some revision traversing links are still broken
This commit is contained in:
parent
476d7810f6
commit
052754b068
18 changed files with 116 additions and 112 deletions
|
@ -32,27 +32,37 @@ class PageTest < Test::Unit::TestCase
|
|||
|
||||
def test_revise
|
||||
@page.revise('HisWay would be MyWay in kinda lame', Time.local(2004, 4, 4, 16, 55), 'MarianneSyhler')
|
||||
assert_equal 2, @page.revisions(true).length, 'Should have two revisions'
|
||||
assert_equal 'MarianneSyhler', @page.current_revision(true).author.to_s, 'Mary should be the author now'
|
||||
@page.reload
|
||||
|
||||
assert_equal 2, @page.revisions.length, 'Should have two revisions'
|
||||
assert_equal 'MarianneSyhler', @page.current_revision.author.to_s, 'Mary should be the author now'
|
||||
assert_equal 'DavidHeinemeierHansson', @page.revisions.first.author.to_s, 'David was the first author'
|
||||
end
|
||||
|
||||
def test_revise_continous_revision
|
||||
@page.revise('HisWay would be MyWay in kinda lame', Time.local(2004, 4, 4, 16, 55), 'MarianneSyhler')
|
||||
assert_equal 2, @page.revisions(true).length
|
||||
@page.reload
|
||||
assert_equal 2, @page.revisions.length
|
||||
assert_equal 'HisWay would be MyWay in kinda lame', @page.content
|
||||
|
||||
@page.current_revision(true)
|
||||
# consecutive revision by the same author within 30 minutes doesn't create a new revision
|
||||
@page.revise('HisWay would be MyWay in kinda update', Time.local(2004, 4, 4, 16, 57), 'MarianneSyhler')
|
||||
assert_equal 2, @page.revisions(true).length
|
||||
assert_equal 'HisWay would be MyWay in kinda update', @page.revisions.last.content
|
||||
assert_equal Time.local(2004, 4, 4, 16, 57), @page.revisions.last.created_at
|
||||
@page.reload
|
||||
assert_equal 2, @page.revisions.length
|
||||
assert_equal 'HisWay would be MyWay in kinda update', @page.content
|
||||
assert_equal Time.local(2004, 4, 4, 16, 57), @page.revised_on
|
||||
|
||||
# but consecutive revision by another author results in a new revision
|
||||
@page.revise('HisWay would be MyWay in the house', Time.local(2004, 4, 4, 16, 58), 'DavidHeinemeierHansson')
|
||||
assert_equal 3, @page.revisions(true).length
|
||||
assert_equal 'HisWay would be MyWay in the house', @page.revisions.last.content
|
||||
@page.reload
|
||||
assert_equal 3, @page.revisions.length
|
||||
assert_equal 'HisWay would be MyWay in the house', @page.content
|
||||
|
||||
# consecutive update after 30 minutes since the last one also creates a new revision,
|
||||
# even when it is by the same author
|
||||
@page.revise('HisWay would be MyWay in my way', Time.local(2004, 4, 4, 17, 30), 'DavidHeinemeierHansson')
|
||||
assert_equal 4, @page.revisions(true).length
|
||||
@page.reload
|
||||
assert_equal 4, @page.revisions.length
|
||||
end
|
||||
|
||||
def test_revise_content_unchanged
|
||||
|
@ -72,7 +82,7 @@ class PageTest < Test::Unit::TestCase
|
|||
@page.revise("spot three", Time.now + 2000, "David")
|
||||
assert_equal 3, @page.revisions(true).length, "Should have three revisions"
|
||||
@page.current_revision(true)
|
||||
@page.rollback(1, Time.now)
|
||||
@page.rollback(0, Time.now)
|
||||
assert_equal "HisWay would be MyWay in kinda ThatWay in HisWay though MyWay \\\\OverThere -- see SmartEngine in that SmartEngineGUI", @page.current_revision(true).content
|
||||
end
|
||||
end
|
||||
|
|
|
@ -245,8 +245,10 @@ class RevisionTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_revisions_diff
|
||||
Revision.create(:page => @page, :content => 'What a blue and lovely morning', :author => Author.new('DavidHeinemeierHansson'))
|
||||
Revision.create(:page => @page, :content => 'What a red and lovely morning today', :author => Author.new('DavidHeinemeierHansson'))
|
||||
Revision.create(:page => @page, :content => 'What a blue and lovely morning',
|
||||
:author => Author.new('DavidHeinemeierHansson'), :revised_at => Time.now)
|
||||
Revision.create(:page => @page, :content => 'What a red and lovely morning today',
|
||||
:author => Author.new('DavidHeinemeierHansson'), :revised_at => Time.now)
|
||||
|
||||
assert_equal "<p>What a <del class=\"diffmod\">blue </del><ins class=\"diffmod\">red " +
|
||||
"</ins>and lovely <del class=\"diffmod\">morning</del><ins class=\"diffmod\">morning " +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue