X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/67dd9e4c9d487bdb5f38a09dc0c99def4989326e..c2447e5ba1efb157296f968783b9575291b1e48b:/test/functional/old_node_controller_test.rb?ds=sidebyside diff --git a/test/functional/old_node_controller_test.rb b/test/functional/old_node_controller_test.rb index efef38ad1..ff776d67f 100644 --- a/test/functional/old_node_controller_test.rb +++ b/test/functional/old_node_controller_test.rb @@ -19,6 +19,10 @@ class OldNodeControllerTest < ActionController::TestCase { :path => "/api/0.6/node/1/2", :method => :get }, { :controller => "old_node", :action => "version", :id => "1", :version => "2" } ) + assert_routing( + { :path => "/api/0.6/node/1/2/redact", :method => :post }, + { :controller => "old_node", :action => "redact", :id => "1", :version => "2" } + ) end ## @@ -193,7 +197,7 @@ class OldNodeControllerTest < ActionController::TestCase do_redact_node(nodes(:node_with_versions_v4), redactions(:example)) - assert_response :forbidden, "shouldn't be OK to redact current version as moderator." + assert_response :bad_request, "shouldn't be OK to redact current version as moderator." end ## @@ -222,7 +226,6 @@ class OldNodeControllerTest < ActionController::TestCase # not even to a logged-in user basic_authorization(users(:public_user).email, "test") - get :version, :id => node.node_id, :version => node.version get :history, :id => node.node_id assert_response :success, "Redaction shouldn't have stopped history working." assert_select "osm node[id=#{node.node_id}][version=#{node.version}]", 0, "redacted node #{node.node_id} version #{node.version} shouldn't be present in the history, even when logged in." @@ -238,14 +241,20 @@ class OldNodeControllerTest < ActionController::TestCase do_redact_node(node, redactions(:example)) assert_response :success, "should be OK to redact old version as moderator." - # check moderator can still see the redacted data + # check moderator can still see the redacted data, when passing + # the appropriate flag get :version, :id => node.node_id, :version => node.version - assert_response :success, "After redaction, node should not be gone for moderator." + assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed." + get :version, :id => node.node_id, :version => node.version, :show_redactions => 'true' + assert_response :success, "After redaction, node should not be gone for moderator, when flag passed." # and when accessed via history get :history, :id => node.node_id assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm node[id=#{node.node_id}][version=#{node.version}]", 1, "node #{node.node_id} version #{node.version} should still be present in the history for moderators." + assert_select "osm node[id=#{node.node_id}][version=#{node.version}]", 0, "node #{node.node_id} version #{node.version} should not be present in the history for moderators when not passing flag." + get :history, :id => node.node_id, :show_redactions => 'true' + assert_response :success, "Redaction shouldn't have stopped history working." + assert_select "osm node[id=#{node.node_id}][version=#{node.version}]", 1, "node #{node.node_id} version #{node.version} should still be present in the history for moderators when passing flag." end # testing that if the moderator drops auth, he can't see the @@ -265,7 +274,6 @@ class OldNodeControllerTest < ActionController::TestCase assert_response :forbidden, "Redacted node shouldn't be visible via the version API." # and when accessed via history - get :version, :id => node.node_id, :version => node.version get :history, :id => node.node_id assert_response :success, "Redaction shouldn't have stopped history working." assert_select "osm node[id=#{node.node_id}][version=#{node.version}]", 0, "redacted node #{node.node_id} version #{node.version} shouldn't be present in the history."