-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[API] Commenting through a token (#1513)
* Start working on a function to add commenting feature through a token * Add authorization * Avoid ruby hash rocket syntax * Facepalm * Start working on a private function for adding comments * Finalize the original function using the private helper * Make comment_by_token method using the private function * Move CommentError and create_comment to CommentHelper * Write first functional test; Introduce wierd 406 error * Fix 406 issue * Add second test and improve responses * Fix test names * Add test for invalid comment * Add recommendations
- Loading branch information
Showing
4 changed files
with
102 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module CommentHelper | ||
class CommentError < ArgumentError | ||
end | ||
|
||
def create_comment(node, user, body) | ||
@comment = node.add_comment(uid: user.uid, body: body) | ||
if user && @comment.save | ||
@comment.notify user | ||
return @comment | ||
else | ||
raise CommentError.new() | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters