3 class NodesControllerTest < ActionDispatch::IntegrationTest
5 # test all routes which lead to this controller
8 { :path => "/node/1", :method => :get },
9 { :controller => "nodes", :action => "show", :id => "1" }
15 sidebar_browse_check :node_path, node.id, "elements/show"
16 assert_select "h4", /^Version/ do
17 assert_select "a[href='#{old_node_path node, 1}']", :text => "1", :count => 1
19 assert_select ".secondary-actions a[href='#{api_node_path node}']", :count => 1
20 assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
23 def test_show_multiple_versions
24 node = create(:node, :with_history, :version => 2)
25 sidebar_browse_check :node_path, node.id, "elements/show"
26 assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
27 assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 1
28 assert_select ".secondary-actions a[href='#{old_node_path node, 2}']", :count => 1
31 def test_show_relation_member
32 member = create(:node)
33 relation = create(:relation)
34 create(:relation_member, :relation => relation, :member => member)
35 sidebar_browse_check :node_path, member.id, "elements/show"
36 assert_select "a[href='#{relation_path relation}']", :count => 1
40 node = create(:node, :visible => false)
41 sidebar_browse_check :node_path, node.id, "elements/show"
42 assert_select "h4", /^Version/ do
43 assert_select "a[href='#{old_node_path node, 1}']", :text => "1", :count => 1
45 assert_select "a[href='#{api_node_path node}']", :count => 0
48 def test_show_redacted
49 node = create(:node, :with_history, :deleted, :version => 2)
50 node_v1 = node.old_nodes.find_by(:version => 1)
51 node_v1.redact!(create(:redaction))
54 assert_response :success
55 assert_template "elements/show"
57 # check that we don't show lat/lon for a redacted node.
58 assert_select ".browse-section", 1
59 assert_select ".browse-section.browse-node", 1
60 assert_select ".browse-section.browse-node .latitude", 0
61 assert_select ".browse-section.browse-node .longitude", 0
64 def test_show_secondary_actions_to_anonymous_user
65 node = create(:node, :with_history)
67 assert_response :success
68 assert_select ".secondary-actions a", :text => "View Details", :count => 0
69 assert_select ".secondary-actions a", :text => "View History", :count => 1
70 assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 0
73 def test_show_secondary_actions_to_regular_user
74 session_for(create(:user))
75 node = create(:node, :with_history)
77 assert_response :success
78 assert_select ".secondary-actions a", :text => "View Details", :count => 0
79 assert_select ".secondary-actions a", :text => "View History", :count => 1
80 assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 0
83 def test_show_secondary_actions_to_moderator
84 session_for(create(:moderator_user))
85 node = create(:node, :with_history)
87 assert_response :success
88 assert_select ".secondary-actions a", :text => "View Details", :count => 0
89 assert_select ".secondary-actions a", :text => "View History", :count => 1
90 assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 1
95 with_settings(:web_timeout => -1) do
98 assert_response :error
99 assert_template :layout => "map"
100 assert_dom "h2", "Timeout Error"
101 assert_dom "p", /#{Regexp.quote("the node with the id #{node.id}")}/