summaryrefslogtreecommitdiff
path: root/test/functional/nodes_controller_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/nodes_controller_test.rb')
-rw-r--r--test/functional/nodes_controller_test.rb51
1 files changed, 48 insertions, 3 deletions
diff --git a/test/functional/nodes_controller_test.rb b/test/functional/nodes_controller_test.rb
index ff9aa68..7559869 100644
--- a/test/functional/nodes_controller_test.rb
+++ b/test/functional/nodes_controller_test.rb
@@ -19,10 +19,55 @@ class NodesControllerTest < ActionController::TestCase
19 assert_response :success 19 assert_response :success
20 end 20 end
21 21
22 def test_create 22 test "create generic node with parent_id provided" do
23 login_as :quentin 23 login_as :quentin
24 post :create, :node => {:slug => 'foobar'}, :parent_id => Node.root.id 24 assert_difference "Node.count", +1 do
25 assert_redirected_to edit_node_path(Node.last) 25 post(
26 :create,
27 :kind => "generic",
28 :parent_id => Node.first.id,
29 :title => "Hello Spaceboy"
30 )
31 end
32
33 assert_response :redirect
34 assert_equal "hello-spaceboy", Node.last.slug
35 assert_equal Node.last.parent_id, Node.first.id
36 assert_equal 1, Node.last.level
37 end
38
39 test "create update node" do
40 login_as :quentin
41 #difference of three because "updates" and "2009" node get created as well
42 assert_difference "Node.count", +3 do
43 post(
44 :create,
45 :kind => "update",
46 :title => "Hello Spaceboy"
47 )
48 end
49
50 assert_response :redirect
51 expected = "updates/#{Time.now.year.to_s}/hello-spaceboy"
52 assert_equal expected, Node.last.unique_name
53 assert_equal 3, Node.last.level
54 end
55
56 test "create top level node" do
57 login_as :quentin
58
59 assert_difference "Node.count", +1 do
60 post(
61 :create,
62 :kind => "top_level",
63 :title => "Hello Spaceboy"
64 )
65 end
66
67 assert_response :redirect
68 expected = "hello-spaceboy"
69 assert_equal expected, Node.last.unique_name
70 assert_equal 1, Node.last.level
26 end 71 end
27 72
28 def test_editing_a_node 73 def test_editing_a_node