diff options
Diffstat (limited to 'test/functional')
| -rw-r--r-- | test/functional/nodes_controller_test.rb | 2 | ||||
| -rw-r--r-- | test/functional/revisions_controller_test.rb | 59 |
2 files changed, 57 insertions, 4 deletions
diff --git a/test/functional/nodes_controller_test.rb b/test/functional/nodes_controller_test.rb index 3dae9db..eca7d93 100644 --- a/test/functional/nodes_controller_test.rb +++ b/test/functional/nodes_controller_test.rb | |||
| @@ -84,7 +84,7 @@ class NodesControllerTest < ActionController::TestCase | |||
| 84 | end | 84 | end |
| 85 | end | 85 | end |
| 86 | 86 | ||
| 87 | def test_editing_a_node | 87 | test "editing a node" do |
| 88 | login_as :quentin | 88 | login_as :quentin |
| 89 | 89 | ||
| 90 | node = Node.find_by_unique_name("fourth_child") | 90 | node = Node.find_by_unique_name("fourth_child") |
diff --git a/test/functional/revisions_controller_test.rb b/test/functional/revisions_controller_test.rb index d752b0e..43001df 100644 --- a/test/functional/revisions_controller_test.rb +++ b/test/functional/revisions_controller_test.rb | |||
| @@ -1,8 +1,61 @@ | |||
| 1 | require 'test_helper' | 1 | require 'test_helper' |
| 2 | 2 | ||
| 3 | class RevisionsControllerTest < ActionController::TestCase | 3 | class RevisionsControllerTest < ActionController::TestCase |
| 4 | # Replace this with your real tests. | 4 | |
| 5 | test "the truth" do | 5 | def setup |
| 6 | assert true | 6 | Node.root.descendants.destroy_all |
| 7 | @user = User.find_by_login("aaron") | ||
| 8 | @node = Node.root.children.create!( :slug => "version_me" ) | ||
| 9 | |||
| 10 | draft = @node.draft | ||
| 11 | draft.body = "first" | ||
| 12 | @node.publish_draft! | ||
| 13 | @node.find_or_create_draft @user | ||
| 14 | draft = @node.draft | ||
| 15 | draft.update_attributes(:body => "second") | ||
| 16 | @node.publish_draft! | ||
| 17 | end | ||
| 18 | |||
| 19 | test "setup" do | ||
| 20 | assert_equal 2, Node.count | ||
| 21 | assert_equal 2, @node.pages.count | ||
| 22 | assert_equal ["first", "second"], @node.pages.map {|p| p.body} | ||
| 23 | end | ||
| 24 | |||
| 25 | test "get list of revisions for a given node" do | ||
| 26 | login_as :quentin | ||
| 27 | get :index, :node_id => @node.id | ||
| 28 | assert_response :success | ||
| 29 | assert_select ".revision", 2 | ||
| 30 | end | ||
| 31 | |||
| 32 | test "showing one revision" do | ||
| 33 | login_as :quentin | ||
| 34 | get :show, :node_id => @node.id, :id => @node.pages.last.id | ||
| 35 | assert_response :success | ||
| 36 | assert_select "strong", "Body" | ||
| 37 | assert_select "td", {:count => 1, :text => "second"} | ||
| 38 | end | ||
| 39 | |||
| 40 | test "diffing two revisions" do | ||
| 41 | login_as :quentin | ||
| 42 | post( | ||
| 43 | :diff, | ||
| 44 | :node_id => @node.id, | ||
| 45 | :start_revision => @node.pages.first.revision, | ||
| 46 | :end_revision => @node.pages.last.revision | ||
| 47 | ) | ||
| 48 | assert_response :success | ||
| 49 | end | ||
| 50 | |||
| 51 | test "restoring a revision" do | ||
| 52 | assert_equal "second", @node.head.body | ||
| 53 | |||
| 54 | login_as :aaron | ||
| 55 | put( :restore, :node_id => @node.id, :id => @node.pages.first.id ) | ||
| 56 | |||
| 57 | @node.reload | ||
| 58 | assert_equal @node.head, @node.pages.first | ||
| 59 | assert_equal "first", @node.head.reload.body | ||
| 7 | end | 60 | end |
| 8 | end | 61 | end |
