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, "browse/feature"
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
21 assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 0
24 def test_show_multiple_versions
25 node = create(:node, :with_history, :version => 2)
26 sidebar_browse_check :node_path, node.id, "browse/feature"
27 assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
28 assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 1
29 assert_select ".secondary-actions a[href='#{old_node_path node, 2}']", :count => 1
32 def test_show_relation_member
33 member = create(:node)
34 relation = create(:relation)
35 create(:relation_member, :relation => relation, :member => member)
36 sidebar_browse_check :node_path, member.id, "browse/feature"
37 assert_select "a[href='#{relation_path relation}']", :count => 1
41 node = create(:node, :visible => false)
42 sidebar_browse_check :node_path, node.id, "browse/feature"
43 assert_select "h4", /^Version/ do
44 assert_select "a[href='#{old_node_path node, 1}']", :text => "1", :count => 1
46 assert_select "a[href='#{api_node_path node}']", :count => 0
49 def test_show_redacted
50 node = create(:node, :with_history, :deleted, :version => 2)
51 node_v1 = node.old_nodes.find_by(:version => 1)
52 node_v1.redact!(create(:redaction))
55 assert_response :success
56 assert_template "feature"
58 # check that we don't show lat/lon for a redacted node.
59 assert_select ".browse-section", 1
60 assert_select ".browse-section.browse-node", 1
61 assert_select ".browse-section.browse-node .latitude", 0
62 assert_select ".browse-section.browse-node .longitude", 0
65 def test_show_secondary_actions_to_anonymous_user
66 node = create(:node, :with_history)
68 assert_response :success
69 assert_select ".secondary-actions a", :text => "View Details", :count => 0
70 assert_select ".secondary-actions a", :text => "View History", :count => 1
71 assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 0
74 def test_show_secondary_actions_to_regular_user
75 session_for(create(:user))
76 node = create(:node, :with_history)
78 assert_response :success
79 assert_select ".secondary-actions a", :text => "View Details", :count => 0
80 assert_select ".secondary-actions a", :text => "View History", :count => 1
81 assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 0
84 def test_show_secondary_actions_to_moderator
85 session_for(create(:moderator_user))
86 node = create(:node, :with_history)
88 assert_response :success
89 assert_select ".secondary-actions a", :text => "View Details", :count => 0
90 assert_select ".secondary-actions a", :text => "View History", :count => 1
91 assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 1
96 with_settings(:web_timeout => -1) do
99 assert_response :error
100 assert_template :layout => "map"
101 assert_dom "h2", "Timeout Error"
102 assert_dom "p", /#{Regexp.quote("the node with the id #{node.id}")}/