Refactor api changeset comment visibility xml tests
This commit is contained in:
parent
84a0c76ab2
commit
c88770e4ce
1 changed files with 19 additions and 40 deletions
|
@ -84,16 +84,7 @@ module Api
|
||||||
|
|
||||||
post api_changeset_comment_visibility_path(comment), :headers => auth_header
|
post api_changeset_comment_visibility_path(comment), :headers => auth_header
|
||||||
|
|
||||||
assert_response :success
|
check_successful_response_xml(comment, :comment_visible => true)
|
||||||
assert_equal "application/xml", response.media_type
|
|
||||||
assert_dom "osm", 1 do
|
|
||||||
assert_dom "> changeset", 1 do
|
|
||||||
assert_dom "> @id", comment.changeset_id.to_s
|
|
||||||
assert_dom "> @comments_count", "1"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
assert comment.reload.visible
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_with_write_changeset_comments_scope_json
|
def test_create_with_write_changeset_comments_scope_json
|
||||||
|
@ -118,16 +109,7 @@ module Api
|
||||||
|
|
||||||
post api_changeset_comment_visibility_path(comment), :headers => auth_header
|
post api_changeset_comment_visibility_path(comment), :headers => auth_header
|
||||||
|
|
||||||
assert_response :success
|
check_successful_response_xml(comment, :comment_visible => true)
|
||||||
assert_equal "application/xml", response.media_type
|
|
||||||
assert_dom "osm", 1 do
|
|
||||||
assert_dom "> changeset", 1 do
|
|
||||||
assert_dom "> @id", comment.changeset_id.to_s
|
|
||||||
assert_dom "> @comments_count", "1"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
assert comment.reload.visible
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_with_write_api_scope_json
|
def test_create_with_write_api_scope_json
|
||||||
|
@ -189,16 +171,7 @@ module Api
|
||||||
|
|
||||||
delete api_changeset_comment_visibility_path(comment), :headers => auth_header
|
delete api_changeset_comment_visibility_path(comment), :headers => auth_header
|
||||||
|
|
||||||
assert_response :success
|
check_successful_response_xml(comment, :comment_visible => false)
|
||||||
assert_equal "application/xml", response.media_type
|
|
||||||
assert_dom "osm", 1 do
|
|
||||||
assert_dom "> changeset", 1 do
|
|
||||||
assert_dom "> @id", comment.changeset_id.to_s
|
|
||||||
assert_dom "> @comments_count", "0"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_not comment.reload.visible
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_with_write_changeset_comments_scope_json
|
def test_destroy_with_write_changeset_comments_scope_json
|
||||||
|
@ -223,16 +196,7 @@ module Api
|
||||||
|
|
||||||
delete api_changeset_comment_visibility_path(comment), :headers => auth_header
|
delete api_changeset_comment_visibility_path(comment), :headers => auth_header
|
||||||
|
|
||||||
assert_response :success
|
check_successful_response_xml(comment, :comment_visible => false)
|
||||||
assert_equal "application/xml", response.media_type
|
|
||||||
assert_dom "osm", 1 do
|
|
||||||
assert_dom "> changeset", 1 do
|
|
||||||
assert_dom "> @id", comment.changeset_id.to_s
|
|
||||||
assert_dom "> @comments_count", "0"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_not comment.reload.visible
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_with_write_api_scope_json
|
def test_destroy_with_write_api_scope_json
|
||||||
|
@ -250,6 +214,21 @@ module Api
|
||||||
|
|
||||||
assert_not comment.reload.visible
|
assert_not comment.reload.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def check_successful_response_xml(comment, comment_visible:)
|
||||||
|
assert_response :success
|
||||||
|
assert_equal "application/xml", response.media_type
|
||||||
|
assert_dom "osm", 1 do
|
||||||
|
assert_dom "> changeset", 1 do
|
||||||
|
assert_dom "> @id", comment.changeset_id.to_s
|
||||||
|
assert_dom "> @comments_count", comment_visible ? "1" : "0"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal comment_visible, comment.reload.visible
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue