1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
require 'test_helper'
class RevisionsControllerTest < ActionController::TestCase
def setup
Node.root.descendants.destroy_all
@user = User.find_by_login("aaron")
@node = Node.root.children.create!( :slug => "version_me" )
draft = @node.draft
draft.body = "first"
@node.publish_draft!
@node.find_or_create_draft @user
draft = @node.draft
draft.update_attributes(:body => "second")
@node.publish_draft!
end
test "setup" do
assert_equal 2, Node.count
assert_equal 2, @node.pages.count
assert_equal ["first", "second"], @node.pages.map {|p| p.body}
end
test "get list of revisions for a given node" do
login_as :quentin
get :index, :node_id => @node.id
assert_response :success
assert_select ".revision", 2
end
test "showing one revision" do
login_as :quentin
get :show, :node_id => @node.id, :id => @node.pages.last.id
assert_response :success
assert_select "strong", "Body"
assert_select "td", {:count => 1, :text => "second"}
end
test "diffing two revisions" do
login_as :quentin
post(
:diff,
:node_id => @node.id,
:start_revision => @node.pages.first.revision,
:end_revision => @node.pages.last.revision
)
assert_response :success
end
test "restoring a revision" do
assert_equal "second", @node.head.body
login_as :aaron
put( :restore, :node_id => @node.id, :id => @node.pages.first.id )
@node.reload
assert_equal @node.head, @node.pages.first
assert_equal "first", @node.head.reload.body
end
end
|