3 class OldNodesControllerTest < ActionDispatch::IntegrationTest
6 { :path => "/node/1/history", :method => :get },
7 { :controller => "old_nodes", :action => "index", :id => "1" }
10 { :path => "/node/1/history/2", :method => :get },
11 { :controller => "old_nodes", :action => "show", :id => "1", :version => "2" }
16 node = create(:node, :with_history)
17 sidebar_browse_check :node_history_path, node.id, "old_elements/index"
20 def test_index_show_redactions_to_unauthorized
21 node = create(:node, :with_history)
23 get node_history_path(:id => node, :params => { :show_redactions => true })
25 assert_response :redirect
28 def test_index_show_redactions_to_regular_user
29 node = create(:node, :with_history)
31 session_for(create(:user))
32 get node_history_path(:id => node, :params => { :show_redactions => true })
34 assert_response :redirect
38 node = create(:node, :with_history)
40 get old_node_path(node, 1)
42 assert_response :success
43 assert_template "old_nodes/show"
44 assert_template :layout => "map"
47 def test_show_redacted_to_unauthorized_users
48 node = create(:node, :with_history, :version => 2)
49 node.old_nodes.find_by(:version => 1).redact!(create(:redaction))
51 get old_node_path(node, 1, :params => { :show_redactions => true })
53 assert_response :redirect
56 def test_show_redacted_to_regular_users
57 node = create(:node, :with_history, :version => 2)
58 node.old_nodes.find_by(:version => 1).redact!(create(:redaction))
60 session_for(create(:user))
61 get old_node_path(node, 1, :params => { :show_redactions => true })
63 assert_response :redirect
66 def test_show_not_found
67 get old_node_path(0, 0)
69 assert_response :not_found
70 assert_template "browse/not_found"
71 assert_template :layout => "map"
72 assert_select "#sidebar_content", /node #0 version 0 could not be found/
76 node = create(:node, :with_history)
78 with_settings(:web_timeout => -1) do
79 get old_node_path(node, 1)
82 assert_response :error
83 assert_template :layout => "map"
84 assert_dom "h2", "Timeout Error"
85 assert_dom "p", /#{Regexp.quote("the node with the id #{node.id}")}/