diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/fixtures/nodes.yml | 13 | ||||
| -rw-r--r-- | test/fixtures/pages.yml | 7 | ||||
| -rw-r--r-- | test/functional/nodes_controller_test.rb | 22 |
3 files changed, 39 insertions, 3 deletions
diff --git a/test/fixtures/nodes.yml b/test/fixtures/nodes.yml index 8574c1b..a0e185b 100644 --- a/test/fixtures/nodes.yml +++ b/test/fixtures/nodes.yml | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | root: | 3 | root: |
| 4 | id: 1 | 4 | id: 1 |
| 5 | lft: 1 | 5 | lft: 1 |
| 6 | rgt: 8 | 6 | rgt: 10 |
| 7 | parent_id: | 7 | parent_id: |
| 8 | slug: | 8 | slug: |
| 9 | unique_name: | 9 | unique_name: |
| @@ -34,4 +34,13 @@ third_child: | |||
| 34 | parent_id: 1 | 34 | parent_id: 1 |
| 35 | draft_id: 102 | 35 | draft_id: 102 |
| 36 | slug: third_child | 36 | slug: third_child |
| 37 | unique_name: third_child \ No newline at end of file | 37 | unique_name: third_child |
| 38 | |||
| 39 | fourth_child: | ||
| 40 | id: 5 | ||
| 41 | lft: 8 | ||
| 42 | rgt: 9 | ||
| 43 | parent_id: 1 | ||
| 44 | draft_id: 103 | ||
| 45 | slug: fourth_child | ||
| 46 | unique_name: fourth_child \ No newline at end of file | ||
diff --git a/test/fixtures/pages.yml b/test/fixtures/pages.yml index 8171b38..271c494 100644 --- a/test/fixtures/pages.yml +++ b/test/fixtures/pages.yml | |||
| @@ -23,4 +23,9 @@ draft2: | |||
| 23 | draft3: | 23 | draft3: |
| 24 | id: 102 | 24 | id: 102 |
| 25 | revision: 1 | 25 | revision: 1 |
| 26 | node_id: 4 \ No newline at end of file | 26 | node_id: 4 |
| 27 | |||
| 28 | draft4: | ||
| 29 | id: 103 | ||
| 30 | revision: 1 | ||
| 31 | node_id: 5 \ No newline at end of file | ||
diff --git a/test/functional/nodes_controller_test.rb b/test/functional/nodes_controller_test.rb index ed8afd8..afe7576 100644 --- a/test/functional/nodes_controller_test.rb +++ b/test/functional/nodes_controller_test.rb | |||
| @@ -22,6 +22,28 @@ class NodesControllerTest < ActionController::TestCase | |||
| 22 | assert_redirected_to node_path(Node.last) | 22 | assert_redirected_to node_path(Node.last) |
| 23 | end | 23 | end |
| 24 | 24 | ||
| 25 | def test_editing_a_node | ||
| 26 | login_as :quentin | ||
| 27 | |||
| 28 | node = Node.find_by_unique_name("fourth_child") | ||
| 29 | |||
| 30 | assert_equal 1, node.pages.length | ||
| 31 | |||
| 32 | draft = node.find_or_create_draft( User.first ) | ||
| 33 | draft.title = "Hello" | ||
| 34 | draft.body = "World" | ||
| 35 | draft.save | ||
| 36 | node.publish_draft! | ||
| 37 | |||
| 38 | get :edit, :id => node.id | ||
| 39 | assert_response :success | ||
| 40 | |||
| 41 | node.reload | ||
| 42 | assert_equal 2, node.pages.length | ||
| 43 | assert_equal "Hello", node.find_or_create_draft( User.first ).title | ||
| 44 | assert_equal "World", node.find_or_create_draft( User.first ).body | ||
| 45 | end | ||
| 46 | |||
| 25 | def test_update_a_draft | 47 | def test_update_a_draft |
| 26 | test_node = Node.create! :slug => "test_node" | 48 | test_node = Node.create! :slug => "test_node" |
| 27 | test_node.move_to_child_of Node.root | 49 | test_node.move_to_child_of Node.root |
