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
33 node = create(:node, :visible => false)
34 sidebar_browse_check :node_path, node.id, "browse/feature"
35 assert_select "h4", /^Version/ do
36 assert_select "a[href='#{old_node_path node, 1}']", :text => "1", :count => 1
38 assert_select "a[href='#{api_node_path node}']", :count => 0
41 def test_show_redacted
42 node = create(:node, :with_history, :deleted, :version => 2)
43 node_v1 = node.old_nodes.find_by(:version => 1)
44 node_v1.redact!(create(:redaction))
47 assert_response :success
48 assert_template "feature"
50 # check that we don't show lat/lon for a redacted node.
51 assert_select ".browse-section", 1
52 assert_select ".browse-section.browse-node", 1
53 assert_select ".browse-section.browse-node .latitude", 0
54 assert_select ".browse-section.browse-node .longitude", 0
57 def test_show_secondary_actions_to_anonymous_user
58 node = create(:node, :with_history)
60 assert_response :success
61 assert_select ".secondary-actions a", :text => "View Details", :count => 0
62 assert_select ".secondary-actions a", :text => "View History", :count => 1
63 assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 0
66 def test_show_secondary_actions_to_regular_user
67 session_for(create(:user))
68 node = create(:node, :with_history)
70 assert_response :success
71 assert_select ".secondary-actions a", :text => "View Details", :count => 0
72 assert_select ".secondary-actions a", :text => "View History", :count => 1
73 assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 0
76 def test_show_secondary_actions_to_moderator
77 session_for(create(:moderator_user))
78 node = create(:node, :with_history)
80 assert_response :success
81 assert_select ".secondary-actions a", :text => "View Details", :count => 0
82 assert_select ".secondary-actions a", :text => "View History", :count => 1
83 assert_select ".secondary-actions a", :text => "View Unredacted History", :count => 1