Commit 19b8adfd authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Make Comments#add take target as separate object.

Instead of listing all target properties inside the comment object
separately, there's now a target property that should contain object
with type,cls,member fields.
parent 52d1d889
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -147,15 +147,16 @@ Comments.prototype = {
     * @param {Number} comment.user_id ID of logged-in user.
     * @param {String} comment.content The text of comment.
     * @param {String} comment.content_html Formatted text of comment.
     * @param {String} comment.type   Type name of target.
     * @param {String} comment.cls    Class name of target.
     * @param {String} comment.member Member name of target.
     * @param {Object} comment.target The target:
     * @param {String} comment.target.type   Type name of target.
     * @param {String} comment.target.cls    Class name of target.
     * @param {String} comment.target.member Member name of target.
     * @param {Function} callback
     * @param {Error} callback.err The error object.
     * @param {Function} callback.id The ID of newly inserted comment.
     */
    add: function(comment, callback) {
        this.targets.ensure(comment, function(err, target_id) {
        this.targets.ensure(comment.target, function(err, target_id) {
            if (err) {
                callback(err);
                return;
+10 −6
Original line number Diff line number Diff line
@@ -124,9 +124,11 @@ describe("Comments", function() {
            content: "Blah.",
            content_html: "<p>Blah.</p>",

            target: {
                type: "class",
                cls: "Ext",
                member: "method-getBody"
            }
        };
        comments.add(com, function(err, id) {
            comments.getById(id, function(err, newCom) {
@@ -143,9 +145,11 @@ describe("Comments", function() {
            content: "Blah.",
            content_html: "<p>Blah.</p>",

            target: {
                type: "class",
                cls: "Blah",
                member: "method-foo"
            }
        };
        comments.add(com, function(err, id) {
            comments.getById(id, function(err, newCom) {