3 class OldNodesControllerTest < ActionDispatch::IntegrationTest
6 { :path => "/node/1/history/2", :method => :get },
7 { :controller => "old_nodes", :action => "show", :id => "1", :version => "2" }
11 def test_visible_with_one_version
12 node = create(:node, :with_history)
13 get old_node_path(node, 1)
14 assert_response :success
15 assert_template "old_nodes/show"
16 assert_template :layout => "map"
17 assert_select "h4", /^Version/ do
18 assert_select "a[href='#{old_node_path node, 1}']", :count => 0
20 assert_select ".secondary-actions a[href='#{node_version_path node, 1}']", :count => 1
21 assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
22 assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
25 def test_visible_with_two_versions
26 node = create(:node, :with_history, :version => 2)
27 get old_node_path(node, 1)
28 assert_response :success
29 assert_template "old_nodes/show"
30 assert_template :layout => "map"
31 assert_select "h4", /^Version/ do
32 assert_select "a[href='#{old_node_path node, 1}']", :count => 0
34 assert_select ".secondary-actions a[href='#{node_version_path node, 1}']", :count => 1
35 assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
36 assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
37 assert_select ".secondary-actions a[href='#{old_node_path node, 2}']", :count => 1
39 get old_node_path(node, 2)
40 assert_response :success
41 assert_template "old_nodes/show"
42 assert_template :layout => "map"
43 assert_select "h4", /^Version/ do
44 assert_select "a[href='#{old_node_path node, 2}']", :count => 0
46 assert_select ".secondary-actions a[href='#{node_version_path node, 2}']", :count => 1
47 assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
48 assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
49 assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 1
53 node = create(:node, :with_history, :deleted, :version => 2)
54 node_v1 = node.old_nodes.find_by(:version => 1)
55 node_v1.redact!(create(:redaction))
56 get old_node_path(node, 1)
57 assert_response :success
58 assert_template "old_nodes/show"
59 assert_template :layout => "map"
60 assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
61 assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 0
62 assert_select ".secondary-actions a[href='#{node_version_path node, 1}']", :count => 0
66 get old_node_path(0, 0)
67 assert_response :not_found
68 assert_template "old_nodes/not_found"
69 assert_template :layout => "map"
70 assert_select "#sidebar_content", /node #0 version 0 could not be found/