Merge pull request #4008 from pestrada/3836-avoid-empty-comments
avoid posting empty comments
This commit is contained in:
commit
1b4f919b5e
3 changed files with 34 additions and 4 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
# Head
|
# Head
|
||||||
|
|
||||||
|
## Bug fixes
|
||||||
|
|
||||||
|
* avoid posting empty comments. [#3836](https://github.com/diaspora/diaspora/issues/3836)
|
||||||
|
|
||||||
## Refactor
|
## Refactor
|
||||||
|
|
||||||
* Refactor people_controller#show and photos_controller#index [#4002](https://github.com/diaspora/diaspora/issues/4002)
|
* Refactor people_controller#show and photos_controller#index [#4002](https://github.com/diaspora/diaspora/issues/4002)
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,15 @@ app.views.CommentStream = app.views.Base.extend({
|
||||||
|
|
||||||
createComment: function(evt) {
|
createComment: function(evt) {
|
||||||
if(evt){ evt.preventDefault(); }
|
if(evt){ evt.preventDefault(); }
|
||||||
this.model.comment(this.$(".comment_box").val())
|
|
||||||
this.$(".comment_box").val("")
|
var commentText = $.trim(this.$('.comment_box').val());
|
||||||
|
if(commentText) {
|
||||||
|
this.model.comment(commentText);
|
||||||
|
this.$(".comment_box").val("");
|
||||||
return this;
|
return this;
|
||||||
|
} else {
|
||||||
|
this.$(".comment_box").val("").focus();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
appendComment: function(comment) {
|
appendComment: function(comment) {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,26 @@ describe("app.views.CommentStream", function(){
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("createComment", function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
jasmine.Ajax.useMock();
|
||||||
|
this.view.render();
|
||||||
|
this.view.expandComments();
|
||||||
|
})
|
||||||
|
|
||||||
|
it("submits the new comment when comment text is not empty", function() {
|
||||||
|
this.view.$(".comment_box").val('a new comment');
|
||||||
|
this.view.createComment();
|
||||||
|
expect(this.view.$(".comment-content p").text()).toEqual("a new comment");
|
||||||
|
})
|
||||||
|
|
||||||
|
it("clears the comment box when there are only spaces", function() {
|
||||||
|
this.view.$(".comment_box").val(' ');
|
||||||
|
this.view.createComment();
|
||||||
|
expect(this.view.$(".comment_box").val()).toEqual("");
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("appendComment", function(){
|
describe("appendComment", function(){
|
||||||
it("appends this.model as 'parent' to the comment", function(){
|
it("appends this.model as 'parent' to the comment", function(){
|
||||||
var comment = new app.models.Comment(factory.comment())
|
var comment = new app.models.Comment(factory.comment())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue