From 5273b18eac02533b11c5b69d27f36fe8c25e0186 Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 31 Jan 2009 23:12:55 +0100 Subject: additional tests and fixtures --- test/fixtures/nodes.yml | 14 ++++++++--- test/fixtures/pages.yml | 7 ------ test/functional/content_controller_test.rb | 6 +++-- 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 @@ one: id: 1 lft: 1 - rgt: 4 + rgt: 6 parent_id: slug: unique_name: @@ -14,5 +14,13 @@ two: lft: 2 rgt: 3 parent_id: 1 - slug: my_first_page - unique_name: root/my_first_page + slug: first_child + unique_name: first_child + +three: + id: 3 + lft: 4 + rgt: 5 + parent_id: 1 + slug: second_child + 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: abstract: MyText body: MyText revision: 1 - -two: - node_id: 1 - title: MyString - abstract: MyText - body: MyText - 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 def test_rendering_a_page assert Node.valid? - assert_not_nil Node.find_by_slug("my_first_page") - get :render_page, :language => 'de', :page_path => ["root", "my_first_page"] + assert_not_nil first_child = Node.find_by_slug("first_child") + first_child.pages.create :title => "First Child" + + get :render_page, :language => 'de', :page_path => ["first_child"] assert_response :success assert_equal "layouts/application", @response.layout 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 def setup @root = Node.find(1) @first_child = Node.find(2) + @second_child = Node.find(3) end def test_creation_of_unique_name @@ -16,11 +17,27 @@ class NodeTest < ActiveSupport::TestCase node = Node.create :slug => 'deep_child' node.move_to_child_of @first_child node.reload - assert_equal 'my_first_page/deep_child', node.unique_name + assert_equal 'first_child/deep_child', node.unique_name end def test_retrieving_page_current + updates = Node.create(:slug => 'updates') + updates.move_to_child_of @root + year = Node.create(:slug => '2008') + year.move_to_child_of updates + + foo = Node.create(:slug => 'foo') + foo.move_to_child_of year + + assert_not_nil Node.find_by_unique_name('updates/2008/foo') + + foo.pages.create :title => "Version 1" + foo.pages.create :title => "Version 2" + foo.pages.create :title => "Version 3" + + page = Node.find_page("updates/2008/foo") + assert_equal page, foo.pages.find_by_revision(3) end def test_retrieving_page_by_revision @@ -28,25 +45,25 @@ class NodeTest < ActiveSupport::TestCase end def test_order_of_pages_by_revision - one = @first_child.pages.create :title => "one" - two = @first_child.pages.create :title => "two" - three = @first_child.pages.create :title => "three" + one = @second_child.pages.create :title => "one" + two = @second_child.pages.create :title => "two" + three = @second_child.pages.create :title => "three" - @first_child.pages.reload + @second_child.pages.reload - assert_equal [1,2,3], @first_child.pages.map { |x| x.revision } + assert_equal [1,2,3], @second_child.pages.map { |x| x.revision } end def test_behavior_of_acts_as_list - one = @first_child.pages.create :title => "one" - two = @first_child.pages.create :title => "two" - three = @first_child.pages.create :title => "three" + one = @second_child.pages.create :title => "one" + two = @second_child.pages.create :title => "two" + three = @second_child.pages.create :title => "three" assert_equal 1, one.revision assert_equal 2, two.revision assert_equal 3, three.revision - assert_equal three, @first_child.pages.last + assert_equal three, @second_child.pages.last assert one.move_to_bottom -- cgit v1.3