X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/03ebd2ac5e8048fcf7c5dea1cbdde6d90f606402..f5af8befa9ffe0c95f4a3c58d2fbb63a2e971ab0:/test/controllers/api/old_nodes_controller_test.rb diff --git a/test/controllers/api/old_nodes_controller_test.rb b/test/controllers/api/old_nodes_controller_test.rb index fb1ee16bc..0c5faa9f9 100644 --- a/test/controllers/api/old_nodes_controller_test.rb +++ b/test/controllers/api/old_nodes_controller_test.rb @@ -194,31 +194,31 @@ module Api end ## - # test the redaction of an old version of a node, while not being - # authorised. - def test_redact_node_unauthorised + # test that, even as moderator, the current version of a node + # can't be redacted. + def test_redact_node_current_version node = create(:node, :with_history, :version => 2) - old_node = node.old_nodes.find_by(:version => 1) + old_node = node.old_nodes.find_by(:version => 2) redaction = create(:redaction) + auth_header = bearer_authorization_header create(:moderator_user) - post node_version_redact_path(*old_node.id), :params => { :redaction => redaction.id } + post node_version_redact_path(*old_node.id), :params => { :redaction => redaction.id }, :headers => auth_header - assert_response :unauthorized, "should need to be authenticated to redact." + assert_response :bad_request, "shouldn't be OK to redact current version as moderator." assert_nil old_node.reload.redaction end ## - # test that, even as moderator, the current version of a node - # can't be redacted. - def test_redact_node_current_version + # test the redaction of an old version of a node, while not being + # authorised. + def test_redact_node_unauthorised node = create(:node, :with_history, :version => 2) - old_node = node.old_nodes.find_by(:version => 2) + old_node = node.old_nodes.find_by(:version => 1) redaction = create(:redaction) - auth_header = bearer_authorization_header create(:moderator_user) - post node_version_redact_path(*old_node.id), :params => { :redaction => redaction.id }, :headers => auth_header + post node_version_redact_path(*old_node.id), :params => { :redaction => redaction.id } - assert_response :bad_request, "shouldn't be OK to redact current version as moderator." + assert_response :unauthorized, "should need to be authenticated to redact." assert_nil old_node.reload.redaction end @@ -289,12 +289,11 @@ module Api # test the unredaction of an old version of a node, while being # authorised as a normal user. def test_unredact_node_normal_user - user = create(:user) node = create(:node, :with_history, :version => 2) old_node = node.old_nodes.find_by(:version => 1) redaction = create(:redaction) old_node.redact!(redaction) - auth_header = bearer_authorization_header user + auth_header = bearer_authorization_header post node_version_redact_path(*old_node.id), :headers => auth_header @@ -306,11 +305,10 @@ module Api # test the unredaction of an old version of a node, while being # authorised as a moderator. def test_unredact_node_moderator - moderator_user = create(:moderator_user) node = create(:node, :with_history, :version => 2) old_node = node.old_nodes.find_by(:version => 1) old_node.redact!(create(:redaction)) - auth_header = bearer_authorization_header moderator_user + auth_header = bearer_authorization_header create(:moderator_user) post node_version_redact_path(*old_node.id), :headers => auth_header