Class: PageTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- PageTest
- Defined in:
- app/models/page_test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_basics ⇒ Object
- #test_continous_revision ⇒ Object
- #test_locking ⇒ Object
- #test_locking_duration ⇒ Object
- #test_revision ⇒ Object
- #test_rollback ⇒ Object
Instance Method Details
#setup ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/models/page_test.rb', line 12 def setup @page = Page.new( MockWeb.new, "FirstPage", "HisWay would be MyWay in kinda ThatWay in HisWay though MyWay \\OverThere -- see SmartEngine in that SmartEngineGUI", Time.local(2004, 4, 4, 16, 50), "DavidHeinemeierHansson" ) end |
#test_basics ⇒ Object
22 23 24 25 |
# File 'app/models/page_test.rb', line 22 def test_basics assert_equal "First Page", @page.plain_name assert_equal "April 4, 2004", @page.pretty_revised_on end |
#test_continous_revision ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/models/page_test.rb', line 61 def test_continous_revision @page.revise("HisWay would be MyWay in kinda lame", Time.local(2004, 4, 4, 16, 55), "MarianneSyhler") assert_equal 2, @page.revisions.length @page.revise("HisWay would be MyWay in kinda update", Time.local(2004, 4, 4, 16, 57), "MarianneSyhler") assert_equal 2, @page.revisions.length assert_equal "HisWay would be MyWay in kinda update", @page.revisions.last.content @page.revise("HisWay would be MyWay in the house", Time.local(2004, 4, 4, 16, 58), "DavidHeinemeierHansson") assert_equal 3, @page.revisions.length assert_equal "HisWay would be MyWay in the house", @page.revisions.last.content @page.revise("HisWay would be MyWay in my way", Time.local(2004, 4, 4, 17, 30), "DavidHeinemeierHansson") assert_equal 4, @page.revisions.length end |
#test_locking ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/page_test.rb', line 27 def test_locking assert !@page.locked?(Time.local(2004, 4, 4, 16, 50)) @page.lock(Time.local(2004, 4, 4, 16, 30), "DavidHeinemeierHansson") assert @page.locked?(Time.local(2004, 4, 4, 16, 50)) assert !@page.locked?(Time.local(2004, 4, 4, 17, 1)) @page.unlock assert !@page.locked?(Time.local(2004, 4, 4, 16, 50)) end |
#test_locking_duration ⇒ Object
40 41 42 43 44 |
# File 'app/models/page_test.rb', line 40 def test_locking_duration @page.lock(Time.local(2004, 4, 4, 16, 30), "DavidHeinemeierHansson") assert_equal 15, @page.lock_duration(Time.local(2004, 4, 4, 16, 45)) end |
#test_revision ⇒ Object
46 47 48 49 50 51 |
# File 'app/models/page_test.rb', line 46 def test_revision @page.revise("HisWay would be MyWay in kinda lame", Time.local(2004, 4, 4, 16, 55), "MarianneSyhler") assert_equal 2, @page.revisions.length, "Should have two revisions" assert_equal "MarianneSyhler", @page., "Mary should be the author now" assert_equal "DavidHeinemeierHansson", @page.revisions.first., "David was the first author" end |
#test_rollback ⇒ Object
53 54 55 56 57 58 59 |
# File 'app/models/page_test.rb', line 53 def test_rollback @page.revise("spot two", Time.now, "David") @page.revise("spot three", Time.now + 2000, "David") assert_equal 3, @page.revisions.length, "Should have three revisions" @page.rollback(1, Time.now) assert_equal "spot two", @page.content end |