summaryrefslogtreecommitdiff
path: root/test/functional/revisions_controller_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/revisions_controller_test.rb')
-rw-r--r--test/functional/revisions_controller_test.rb59
1 files changed, 56 insertions, 3 deletions
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 @@
1require 'test_helper' 1require 'test_helper'
2 2
3class RevisionsControllerTest < ActionController::TestCase 3class 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
8end 61end