Use fewer element versions in redaction tests
This commit is contained in:
parent
c134cabab2
commit
ef9d39ece0
3 changed files with 30 additions and 30 deletions
|
@ -213,11 +213,11 @@ module Api
|
||||||
# test that, even as moderator, the current version of a node
|
# test that, even as moderator, the current version of a node
|
||||||
# can't be redacted.
|
# can't be redacted.
|
||||||
def test_redact_node_current_version
|
def test_redact_node_current_version
|
||||||
node = create(:node, :with_history, :version => 4)
|
node = create(:node, :with_history, :version => 2)
|
||||||
redaction = create(:redaction)
|
redaction = create(:redaction)
|
||||||
auth_header = bearer_authorization_header create(:moderator_user)
|
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."
|
assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
|
||||||
end
|
end
|
||||||
|
@ -250,17 +250,17 @@ module Api
|
||||||
# test the redaction of an old version of a node, while being
|
# test the redaction of an old version of a node, while being
|
||||||
# authorised as a moderator.
|
# authorised as a moderator.
|
||||||
def test_redact_node_moderator
|
def test_redact_node_moderator
|
||||||
node = create(:node, :with_history, :version => 4)
|
node = create(:node, :with_history, :version => 2)
|
||||||
node_v3 = node.old_nodes.find_by(:version => 3)
|
node_v1 = node.old_nodes.find_by(:version => 1)
|
||||||
redaction = create(:redaction)
|
redaction = create(:redaction)
|
||||||
auth_header = bearer_authorization_header create(:moderator_user)
|
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."
|
assert_response :success, "should be OK to redact old version as moderator."
|
||||||
node_v3.reload
|
node_v1.reload
|
||||||
assert_predicate node_v3, :redacted?
|
assert_predicate node_v1, :redacted?
|
||||||
assert_equal redaction, node_v3.redaction
|
assert_equal redaction, node_v1.redaction
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -331,10 +331,10 @@ module Api
|
||||||
private
|
private
|
||||||
|
|
||||||
def do_redact_redactable_node(headers = {})
|
def do_redact_redactable_node(headers = {})
|
||||||
node = create(:node, :with_history, :version => 4)
|
node = create(:node, :with_history, :version => 2)
|
||||||
redaction = create(:redaction)
|
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
|
end
|
||||||
|
|
||||||
def check_not_found_id_version(id, version)
|
def check_not_found_id_version(id, version)
|
||||||
|
|
|
@ -204,11 +204,11 @@ module Api
|
||||||
# test that, even as moderator, the current version of a relation
|
# test that, even as moderator, the current version of a relation
|
||||||
# can't be redacted.
|
# can't be redacted.
|
||||||
def test_redact_relation_current_version
|
def test_redact_relation_current_version
|
||||||
relation = create(:relation, :with_history, :version => 4)
|
relation = create(:relation, :with_history, :version => 2)
|
||||||
redaction = create(:redaction)
|
redaction = create(:redaction)
|
||||||
auth_header = bearer_authorization_header create(:moderator_user)
|
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."
|
assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
|
||||||
end
|
end
|
||||||
|
@ -241,17 +241,17 @@ module Api
|
||||||
# test the redaction of an old version of a relation, while being
|
# test the redaction of an old version of a relation, while being
|
||||||
# authorised as a moderator.
|
# authorised as a moderator.
|
||||||
def test_redact_relation_moderator
|
def test_redact_relation_moderator
|
||||||
relation = create(:relation, :with_history, :version => 4)
|
relation = create(:relation, :with_history, :version => 2)
|
||||||
relation_v3 = relation.old_relations.find_by(:version => 3)
|
relation_v1 = relation.old_relations.find_by(:version => 1)
|
||||||
redaction = create(:redaction)
|
redaction = create(:redaction)
|
||||||
auth_header = bearer_authorization_header create(:moderator_user)
|
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."
|
assert_response :success, "should be OK to redact old version as moderator."
|
||||||
relation_v3.reload
|
relation_v1.reload
|
||||||
assert_predicate relation_v3, :redacted?
|
assert_predicate relation_v1, :redacted?
|
||||||
assert_equal redaction, relation_v3.redaction
|
assert_equal redaction, relation_v1.redaction
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -320,10 +320,10 @@ module Api
|
||||||
private
|
private
|
||||||
|
|
||||||
def do_redact_redactable_relation(headers = {})
|
def do_redact_redactable_relation(headers = {})
|
||||||
relation = create(:relation, :with_history, :version => 4)
|
relation = create(:relation, :with_history, :version => 2)
|
||||||
redaction = create(:redaction)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -215,11 +215,11 @@ module Api
|
||||||
# test that, even as moderator, the current version of a way
|
# test that, even as moderator, the current version of a way
|
||||||
# can't be redacted.
|
# can't be redacted.
|
||||||
def test_redact_way_current_version
|
def test_redact_way_current_version
|
||||||
way = create(:way, :with_history, :version => 4)
|
way = create(:way, :with_history, :version => 2)
|
||||||
redaction = create(:redaction)
|
redaction = create(:redaction)
|
||||||
auth_header = bearer_authorization_header create(:moderator_user)
|
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."
|
assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
|
||||||
end
|
end
|
||||||
|
@ -252,17 +252,17 @@ module Api
|
||||||
# test the redaction of an old version of a way, while being
|
# test the redaction of an old version of a way, while being
|
||||||
# authorised as a moderator.
|
# authorised as a moderator.
|
||||||
def test_redact_way_moderator
|
def test_redact_way_moderator
|
||||||
way = create(:way, :with_history, :version => 4)
|
way = create(:way, :with_history, :version => 2)
|
||||||
way_v3 = way.old_ways.find_by(:version => 3)
|
way_v1 = way.old_ways.find_by(:version => 1)
|
||||||
redaction = create(:redaction)
|
redaction = create(:redaction)
|
||||||
auth_header = bearer_authorization_header create(:moderator_user)
|
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."
|
assert_response :success, "should be OK to redact old version as moderator."
|
||||||
way_v3.reload
|
way_v1.reload
|
||||||
assert_predicate way_v3, :redacted?
|
assert_predicate way_v1, :redacted?
|
||||||
assert_equal redaction, way_v3.redaction
|
assert_equal redaction, way_v1.redaction
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -354,10 +354,10 @@ module Api
|
||||||
end
|
end
|
||||||
|
|
||||||
def do_redact_redactable_way(headers = {})
|
def do_redact_redactable_way(headers = {})
|
||||||
way = create(:way, :with_history, :version => 4)
|
way = create(:way, :with_history, :version => 2)
|
||||||
redaction = create(:redaction)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue