- def test_hide_with_write_changeset_comments_scope
- comment = create(:changeset_comment)
- auth_header = bearer_authorization_header create(:moderator_user), :scopes => %w[write_changeset_comments]
-
- post changeset_comment_hide_path(comment), :headers => auth_header
-
- assert_response :success
- assert_not comment.reload.visible
- end
-
- def test_hide_with_write_api_scope
- comment = create(:changeset_comment)
- auth_header = bearer_authorization_header create(:moderator_user), :scopes => %w[write_api]
-
- post changeset_comment_hide_path(comment), :headers => auth_header
-
- assert_response :success
- assert_not comment.reload.visible
- end
-
- def test_unhide_by_unauthorized
- comment = create(:changeset_comment, :visible => false)
-
- post changeset_comment_unhide_path(comment)
-
- assert_response :unauthorized
- assert_not comment.reload.visible
- end
-
- def test_unhide_by_normal_user
- comment = create(:changeset_comment, :visible => false)
- auth_header = bearer_authorization_header
-
- post changeset_comment_unhide_path(comment), :headers => auth_header
-
- assert_response :forbidden
- assert_not comment.reload.visible
- end
-
- def test_unhide_missing_comment
- auth_header = bearer_authorization_header create(:moderator_user)
-
- post changeset_comment_unhide_path(999111), :headers => auth_header
-
- assert_response :not_found
- end
-
- def test_unhide_without_required_scope
- comment = create(:changeset_comment, :visible => false)
- auth_header = bearer_authorization_header create(:moderator_user), :scopes => %w[read_prefs]
-
- post changeset_comment_unhide_path(comment), :headers => auth_header
-
- assert_response :forbidden
- assert_not comment.reload.visible
- end
-
- def test_unhide_with_write_changeset_comments_scope
- comment = create(:changeset_comment, :visible => false)
- auth_header = bearer_authorization_header create(:moderator_user), :scopes => %w[write_changeset_comments]
-
- post changeset_comment_unhide_path(comment), :headers => auth_header
-
- assert_response :success
- assert comment.reload.visible
- end
-
- def test_unhide_with_write_api_scope
- comment = create(:changeset_comment, :visible => false)
- auth_header = bearer_authorization_header create(:moderator_user), :scopes => %w[write_api]
-
- post changeset_comment_unhide_path(comment), :headers => auth_header
-
- assert_response :success
- assert comment.reload.visible
+ ##
+ # check that certain comments exist in the output in the specified order
+ def assert_comments_in_order(comments)
+ assert_dom "osm > comment", comments.size do |dom_comments|
+ comments.zip(dom_comments).each do |comment, dom_comment|
+ assert_dom dom_comment, "> @id", comment.id.to_s
+ assert_dom dom_comment, "> @uid", comment.author.id.to_s
+ assert_dom dom_comment, "> @user", comment.author.display_name
+ assert_dom dom_comment, "> text", comment.body
+ end
+ end