# 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 => 4)
+ node = create(:node, :with_history, :version => 2)
redaction = create(:redaction)
auth_header = bearer_authorization_header create(:moderator_user)
- post node_version_redact_path(node, 4), :params => { :redaction => redaction.id }, :headers => auth_header
+ post node_version_redact_path(node, 2), :params => { :redaction => redaction.id }, :headers => auth_header
assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
end
# test the redaction of an old version of a node, while being
# authorised as a moderator.
def test_redact_node_moderator
- node = create(:node, :with_history, :version => 4)
- node_v3 = node.old_nodes.find_by(:version => 3)
+ node = create(:node, :with_history, :version => 2)
+ node_v1 = node.old_nodes.find_by(:version => 1)
redaction = create(:redaction)
auth_header = bearer_authorization_header create(:moderator_user)
- post node_version_redact_path(*node_v3.id), :params => { :redaction => redaction.id }, :headers => auth_header
+ post node_version_redact_path(*node_v1.id), :params => { :redaction => redaction.id }, :headers => auth_header
assert_response :success, "should be OK to redact old version as moderator."
- node_v3.reload
- assert_predicate node_v3, :redacted?
- assert_equal redaction, node_v3.redaction
+ node_v1.reload
+ assert_predicate node_v1, :redacted?
+ assert_equal redaction, node_v1.redaction
end
##
private
def do_redact_redactable_node(headers = {})
- node = create(:node, :with_history, :version => 4)
+ node = create(:node, :with_history, :version => 2)
redaction = create(:redaction)
- post node_version_redact_path(node, 3), :params => { :redaction => redaction.id }, :headers => headers
+ post node_version_redact_path(node, 1), :params => { :redaction => redaction.id }, :headers => headers
end
def check_not_found_id_version(id, version)
# test that, even as moderator, the current version of a relation
# can't be redacted.
def test_redact_relation_current_version
- relation = create(:relation, :with_history, :version => 4)
+ relation = create(:relation, :with_history, :version => 2)
redaction = create(:redaction)
auth_header = bearer_authorization_header create(:moderator_user)
- post relation_version_redact_path(relation, 4), :params => { :redaction => redaction.id }, :headers => auth_header
+ post relation_version_redact_path(relation, 2), :params => { :redaction => redaction.id }, :headers => auth_header
assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
end
# test the redaction of an old version of a relation, while being
# authorised as a moderator.
def test_redact_relation_moderator
- relation = create(:relation, :with_history, :version => 4)
- relation_v3 = relation.old_relations.find_by(:version => 3)
+ relation = create(:relation, :with_history, :version => 2)
+ relation_v1 = relation.old_relations.find_by(:version => 1)
redaction = create(:redaction)
auth_header = bearer_authorization_header create(:moderator_user)
- post relation_version_redact_path(*relation_v3.id), :params => { :redaction => redaction.id }, :headers => auth_header
+ post relation_version_redact_path(*relation_v1.id), :params => { :redaction => redaction.id }, :headers => auth_header
assert_response :success, "should be OK to redact old version as moderator."
- relation_v3.reload
- assert_predicate relation_v3, :redacted?
- assert_equal redaction, relation_v3.redaction
+ relation_v1.reload
+ assert_predicate relation_v1, :redacted?
+ assert_equal redaction, relation_v1.redaction
end
##
private
def do_redact_redactable_relation(headers = {})
- relation = create(:relation, :with_history, :version => 4)
+ relation = create(:relation, :with_history, :version => 2)
redaction = create(:redaction)
- post relation_version_redact_path(relation, 3), :params => { :redaction => redaction.id }, :headers => headers
+ post relation_version_redact_path(relation, 1), :params => { :redaction => redaction.id }, :headers => headers
end
end
end
# test that, even as moderator, the current version of a way
# can't be redacted.
def test_redact_way_current_version
- way = create(:way, :with_history, :version => 4)
+ way = create(:way, :with_history, :version => 2)
redaction = create(:redaction)
auth_header = bearer_authorization_header create(:moderator_user)
- post way_version_redact_path(way, 4), :params => { :redaction => redaction.id }, :headers => auth_header
+ post way_version_redact_path(way, 2), :params => { :redaction => redaction.id }, :headers => auth_header
assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
end
# test the redaction of an old version of a way, while being
# authorised as a moderator.
def test_redact_way_moderator
- way = create(:way, :with_history, :version => 4)
- way_v3 = way.old_ways.find_by(:version => 3)
+ way = create(:way, :with_history, :version => 2)
+ way_v1 = way.old_ways.find_by(:version => 1)
redaction = create(:redaction)
auth_header = bearer_authorization_header create(:moderator_user)
- post way_version_redact_path(*way_v3.id), :params => { :redaction => redaction.id }, :headers => auth_header
+ post way_version_redact_path(*way_v1.id), :params => { :redaction => redaction.id }, :headers => auth_header
assert_response :success, "should be OK to redact old version as moderator."
- way_v3.reload
- assert_predicate way_v3, :redacted?
- assert_equal redaction, way_v3.redaction
+ way_v1.reload
+ assert_predicate way_v1, :redacted?
+ assert_equal redaction, way_v1.redaction
end
##
end
def do_redact_redactable_way(headers = {})
- way = create(:way, :with_history, :version => 4)
+ way = create(:way, :with_history, :version => 2)
redaction = create(:redaction)
- post way_version_redact_path(way.id, 2), :params => { :redaction => redaction.id }, :headers => headers
+ post way_version_redact_path(way.id, 1), :params => { :redaction => redaction.id }, :headers => headers
end
end
end