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 | |
| parent | 673d7da787a8bf5c6477871557f27352edbb5a64 (diff) | |
additional tests and fixtures
Diffstat (limited to 'test')
| -rw-r--r-- | test/fixtures/nodes.yml | 14 | ||||
| -rw-r--r-- | test/fixtures/pages.yml | 7 | ||||
| -rw-r--r-- | test/functional/content_controller_test.rb | 6 | ||||
| -rw-r--r-- | test/unit/node_test.rb | 37 |
4 files changed, 42 insertions, 22 deletions
diff --git a/test/fixtures/nodes.yml b/test/fixtures/nodes.yml index 3f89f6d..07ac089 100644 --- a/test/fixtures/nodes.yml +++ b/test/fixtures/nodes.yml | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | one: | 3 | one: |
| 4 | id: 1 | 4 | id: 1 |
| 5 | lft: 1 | 5 | lft: 1 |
| 6 | rgt: 4 | 6 | rgt: 6 |
| 7 | parent_id: | 7 | parent_id: |
| 8 | slug: | 8 | slug: |
| 9 | unique_name: | 9 | unique_name: |
| @@ -14,5 +14,13 @@ two: | |||
| 14 | lft: 2 | 14 | lft: 2 |
| 15 | rgt: 3 | 15 | rgt: 3 |
| 16 | parent_id: 1 | 16 | parent_id: 1 |
| 17 | slug: my_first_page | 17 | slug: first_child |
| 18 | unique_name: root/my_first_page | 18 | unique_name: first_child |
| 19 | |||
| 20 | three: | ||
| 21 | id: 3 | ||
| 22 | lft: 4 | ||
| 23 | rgt: 5 | ||
| 24 | parent_id: 1 | ||
| 25 | slug: second_child | ||
| 26 | unique_name: second_child \ No newline at end of file | ||
diff --git a/test/fixtures/pages.yml b/test/fixtures/pages.yml index 2b1cad1..1ec3702 100644 --- a/test/fixtures/pages.yml +++ b/test/fixtures/pages.yml | |||
| @@ -6,10 +6,3 @@ one: | |||
| 6 | abstract: MyText | 6 | abstract: MyText |
| 7 | body: MyText | 7 | body: MyText |
| 8 | revision: 1 | 8 | revision: 1 |
| 9 | |||
| 10 | two: | ||
| 11 | node_id: 1 | ||
| 12 | title: MyString | ||
| 13 | abstract: MyText | ||
| 14 | body: MyText | ||
| 15 | revision: 1 | ||
diff --git a/test/functional/content_controller_test.rb b/test/functional/content_controller_test.rb index 15e1299..76a9b24 100644 --- a/test/functional/content_controller_test.rb +++ b/test/functional/content_controller_test.rb | |||
| @@ -14,8 +14,10 @@ class ContentControllerTest < ActionController::TestCase | |||
| 14 | 14 | ||
| 15 | def test_rendering_a_page | 15 | def test_rendering_a_page |
| 16 | assert Node.valid? | 16 | assert Node.valid? |
| 17 | assert_not_nil Node.find_by_slug("my_first_page") | 17 | assert_not_nil first_child = Node.find_by_slug("first_child") |
| 18 | get :render_page, :language => 'de', :page_path => ["root", "my_first_page"] | 18 | first_child.pages.create :title => "First Child" |
| 19 | |||
| 20 | get :render_page, :language => 'de', :page_path => ["first_child"] | ||
| 19 | assert_response :success | 21 | assert_response :success |
| 20 | assert_equal "layouts/application", @response.layout | 22 | assert_equal "layouts/application", @response.layout |
| 21 | end | 23 | end |
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 | ||
