From 5b06d137fc6143ff679d1ce6048c4149ca23f4e2 Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 31 Jan 2009 13:05:48 +0100 Subject: connected page and node model + some minor tweaks --- test/fixtures/nodes.yml | 12 +++++++++++- test/unit/node_test.rb | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/fixtures/nodes.yml b/test/fixtures/nodes.yml index 9879d9f..3f89f6d 100644 --- a/test/fixtures/nodes.yml +++ b/test/fixtures/nodes.yml @@ -3,6 +3,16 @@ one: id: 1 lft: 1 - rgt: 2 + rgt: 4 + parent_id: + slug: + unique_name: + + +two: + id: 2 + lft: 2 + rgt: 3 + parent_id: 1 slug: my_first_page unique_name: root/my_first_page diff --git a/test/unit/node_test.rb b/test/unit/node_test.rb index a311b84..14fdad0 100644 --- a/test/unit/node_test.rb +++ b/test/unit/node_test.rb @@ -1,8 +1,49 @@ require 'test_helper' class NodeTest < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true + + def setup + @root = Node.find(1) + @first_child = Node.find(2) + end + + def test_creation_of_unique_name + node = Node.create :slug => 'child' + node.move_to_child_of @root + node.reload + assert_equal 'child', node.unique_name + + 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 + end + + def test_retrieving_page_current + + end + + def test_retrieving_page_by_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" + + assert_equal 1, one.revision + assert_equal 2, two.revision + assert_equal 3, three.revision + + assert_equal three, @first_child.pages.last + + assert one.move_to_bottom + + one.reload; two.reload; three.reload; + + assert_equal 3, one.revision + assert_equal 1, two.revision + assert_equal 2, three.revision end end -- cgit v1.3