diff options
| author | hukl <hukl@eight.local> | 2009-01-31 23:12:55 +0100 |
|---|---|---|
| committer | hukl <hukl@eight.local> | 2009-01-31 23:12:55 +0100 |
| commit | 5273b18eac02533b11c5b69d27f36fe8c25e0186 (patch) | |
| tree | c04b70c639b0d9987c60006d8cbf77a13c49cf43 /test/unit/node_test.rb | |
| parent | 673d7da787a8bf5c6477871557f27352edbb5a64 (diff) | |
additional tests and fixtures
Diffstat (limited to 'test/unit/node_test.rb')
| -rw-r--r-- | test/unit/node_test.rb | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/test/unit/node_test.rb b/test/unit/node_test.rb index 049c71c..56012d6 100644 --- a/test/unit/node_test.rb +++ b/test/unit/node_test.rb | |||
| @@ -5,6 +5,7 @@ class NodeTest < ActiveSupport::TestCase | |||
| 5 | def setup | 5 | def setup |
| 6 | @root = Node.find(1) | 6 | @root = Node.find(1) |
| 7 | @first_child = Node.find(2) | 7 | @first_child = Node.find(2) |
| 8 | @second_child = Node.find(3) | ||
| 8 | end | 9 | end |
| 9 | 10 | ||
| 10 | def test_creation_of_unique_name | 11 | def test_creation_of_unique_name |
| @@ -16,11 +17,27 @@ class NodeTest < ActiveSupport::TestCase | |||
| 16 | node = Node.create :slug => 'deep_child' | 17 | node = Node.create :slug => 'deep_child' |
| 17 | node.move_to_child_of @first_child | 18 | node.move_to_child_of @first_child |
| 18 | node.reload | 19 | node.reload |
| 19 | assert_equal 'my_first_page/deep_child', node.unique_name | 20 | assert_equal 'first_child/deep_child', node.unique_name |
| 20 | end | 21 | end |
| 21 | 22 | ||
| 22 | def test_retrieving_page_current | 23 | def test_retrieving_page_current |
| 24 | updates = Node.create(:slug => 'updates') | ||
| 25 | updates.move_to_child_of @root | ||
| 23 | 26 | ||
| 27 | year = Node.create(:slug => '2008') | ||
| 28 | year.move_to_child_of updates | ||
| 29 | |||
| 30 | foo = Node.create(:slug => 'foo') | ||
| 31 | foo.move_to_child_of year | ||
| 32 | |||
| 33 | assert_not_nil Node.find_by_unique_name('updates/2008/foo') | ||
| 34 | |||
| 35 | foo.pages.create :title => "Version 1" | ||
| 36 | foo.pages.create :title => "Version 2" | ||
| 37 | foo.pages.create :title => "Version 3" | ||
| 38 | |||
| 39 | page = Node.find_page("updates/2008/foo") | ||
| 40 | assert_equal page, foo.pages.find_by_revision(3) | ||
| 24 | end | 41 | end |
| 25 | 42 | ||
| 26 | def test_retrieving_page_by_revision | 43 | def test_retrieving_page_by_revision |
| @@ -28,25 +45,25 @@ class NodeTest < ActiveSupport::TestCase | |||
| 28 | end | 45 | end |
| 29 | 46 | ||
| 30 | def test_order_of_pages_by_revision | 47 | def test_order_of_pages_by_revision |
| 31 | one = @first_child.pages.create :title => "one" | 48 | one = @second_child.pages.create :title => "one" |
| 32 | two = @first_child.pages.create :title => "two" | 49 | two = @second_child.pages.create :title => "two" |
| 33 | three = @first_child.pages.create :title => "three" | 50 | three = @second_child.pages.create :title => "three" |
| 34 | 51 | ||
| 35 | @first_child.pages.reload | 52 | @second_child.pages.reload |
| 36 | 53 | ||
| 37 | assert_equal [1,2,3], @first_child.pages.map { |x| x.revision } | 54 | assert_equal [1,2,3], @second_child.pages.map { |x| x.revision } |
| 38 | end | 55 | end |
| 39 | 56 | ||
| 40 | def test_behavior_of_acts_as_list | 57 | def test_behavior_of_acts_as_list |
| 41 | one = @first_child.pages.create :title => "one" | 58 | one = @second_child.pages.create :title => "one" |
| 42 | two = @first_child.pages.create :title => "two" | 59 | two = @second_child.pages.create :title => "two" |
| 43 | three = @first_child.pages.create :title => "three" | 60 | three = @second_child.pages.create :title => "three" |
| 44 | 61 | ||
| 45 | assert_equal 1, one.revision | 62 | assert_equal 1, one.revision |
| 46 | assert_equal 2, two.revision | 63 | assert_equal 2, two.revision |
| 47 | assert_equal 3, three.revision | 64 | assert_equal 3, three.revision |
| 48 | 65 | ||
| 49 | assert_equal three, @first_child.pages.last | 66 | assert_equal three, @second_child.pages.last |
| 50 | 67 | ||
| 51 | assert one.move_to_bottom | 68 | assert one.move_to_bottom |
| 52 | 69 | ||
