fixing commenting
Added jamisne tests for comments Added 2 jasmine tests for fixing commenting Bugfix: #4005 added changelog entry
This commit is contained in:
parent
5a821efa18
commit
5caa46cc83
3 changed files with 37 additions and 17 deletions
|
|
@ -20,6 +20,8 @@
|
||||||
* Disable submit button in sign up form after submission to avoid email already exists error [#4506](https://github.com/diaspora/diaspora/issues/4506)
|
* Disable submit button in sign up form after submission to avoid email already exists error [#4506](https://github.com/diaspora/diaspora/issues/4506)
|
||||||
* Do not pull the 404 pages assets from Amazon S3 [#4501](https://github.com/diaspora/diaspora/pull/4501)
|
* Do not pull the 404 pages assets from Amazon S3 [#4501](https://github.com/diaspora/diaspora/pull/4501)
|
||||||
* Fix counter background does not cover more than 2 digits on profile [#4499](https://github.com/diaspora/diaspora/issues/4499)
|
* Fix counter background does not cover more than 2 digits on profile [#4499](https://github.com/diaspora/diaspora/issues/4499)
|
||||||
|
* Fix commenting upon submission fail [#4005] (https://github.com/diaspora/diaspora/issues/4005)
|
||||||
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* Add oEmbed content to the mobile view [#4343](https://github.com/diaspora/diaspora/pull/4353)
|
* Add oEmbed content to the mobile view [#4343](https://github.com/diaspora/diaspora/pull/4353)
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,18 @@ app.collections.Comments = Backbone.Collection.extend({
|
||||||
var self = this
|
var self = this
|
||||||
|
|
||||||
var comment = new app.models.Comment({text: text })
|
var comment = new app.models.Comment({text: text })
|
||||||
, deferred = comment.save({}, {url : self.url()})
|
|
||||||
|
|
||||||
comment.set({author: app.currentUser.toJSON(), parent: self.post })
|
var deferred = comment.save({}, {
|
||||||
|
url : self.url(),
|
||||||
|
success: function() {
|
||||||
|
comment.set({author: app.currentUser.toJSON(), parent: self.post })
|
||||||
|
self.add(comment)
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
|
||||||
this.add(comment)
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return deferred
|
return deferred
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -28,26 +28,38 @@ describe("app.views.CommentStream", function(){
|
||||||
expect($.fn.autoResize.mostRecentCall.object.selector).toBe("textarea")
|
expect($.fn.autoResize.mostRecentCall.object.selector).toBe("textarea")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("createComment", function() {
|
describe("createComment", function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
jasmine.Ajax.useMock();
|
jasmine.Ajax.useMock();
|
||||||
this.view.render();
|
this.view.render();
|
||||||
this.view.expandComments();
|
this.view.expandComments();
|
||||||
})
|
})
|
||||||
|
|
||||||
it("submits the new comment when comment text is not empty", function() {
|
it("submits the new comment when comment text is not empty", function() {
|
||||||
this.view.$(".comment_box").val('a new comment');
|
this.view.$(".comment_box").val('a new comment');
|
||||||
this.view.createComment();
|
this.view.createComment();
|
||||||
expect(this.view.$(".comment-content p").text()).toEqual("a new comment");
|
comments = mostRecentAjaxRequest();
|
||||||
|
params = JSON.parse(comments.params)
|
||||||
|
expect(params.text).toEqual("a new comment");
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("comment doesn't get added if the submission fails", function(){
|
||||||
|
this.view.render();
|
||||||
|
var form = this.view.$("form")
|
||||||
|
var submitCallback = jasmine.createSpy().andReturn(false);form.submit(submitCallback);
|
||||||
|
var e = $.Event("keydown", { keyCode: 13 });
|
||||||
|
e.shiftKey = false;
|
||||||
|
this.view.keyDownOnCommentBox(e);
|
||||||
|
expect(submitCallback).not.toHaveBeenCalled();
|
||||||
|
})
|
||||||
|
|
||||||
it("clears the comment box when there are only spaces", function() {
|
it("clears the comment box when there are only spaces", function() {
|
||||||
this.view.$(".comment_box").val(' ');
|
this.view.$(".comment_box").val(' ');
|
||||||
this.view.createComment();
|
this.view.createComment();
|
||||||
expect(this.view.$(".comment_box").val()).toEqual("");
|
expect(this.view.$(".comment_box").val()).toEqual("");
|
||||||
})
|
})
|
||||||
|
|
||||||
it("resets comment box height", function() {
|
it("resets comment box height", function() {
|
||||||
this.view.$(".comment_box").val('a new comment');
|
this.view.$(".comment_box").val('a new comment');
|
||||||
this.view.createComment();
|
this.view.createComment();
|
||||||
|
|
@ -80,32 +92,32 @@ describe("app.views.CommentStream", function(){
|
||||||
expect(this.view.$("textarea").val()).toEqual("great post!");
|
expect(this.view.$("textarea").val()).toEqual("great post!");
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("pressing a key when typing on the new comment box", function(){
|
describe("pressing a key when typing on the new comment box", function(){
|
||||||
it("should not submit the form when enter key is pressed", function(){
|
it("should not submit the form when enter key is pressed", function(){
|
||||||
this.view.render();
|
this.view.render();
|
||||||
var form = this.view.$("form")
|
var form = this.view.$("form")
|
||||||
var submitCallback = jasmine.createSpy().andReturn(false);form.submit(submitCallback);
|
var submitCallback = jasmine.createSpy().andReturn(false);form.submit(submitCallback);
|
||||||
|
|
||||||
var e = $.Event("keydown", { keyCode: 13 });
|
var e = $.Event("keydown", { keyCode: 13 });
|
||||||
e.shiftKey = false;
|
e.shiftKey = false;
|
||||||
this.view.keyDownOnCommentBox(e);
|
this.view.keyDownOnCommentBox(e);
|
||||||
|
|
||||||
expect(submitCallback).not.toHaveBeenCalled();
|
expect(submitCallback).not.toHaveBeenCalled();
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should submit the form when enter is pressed with ctrl", function(){
|
it("should submit the form when enter is pressed with ctrl", function(){
|
||||||
this.view.render();
|
this.view.render();
|
||||||
var form = this.view.$("form")
|
var form = this.view.$("form")
|
||||||
var submitCallback = jasmine.createSpy().andReturn(false);
|
var submitCallback = jasmine.createSpy().andReturn(false);
|
||||||
form.submit(submitCallback);
|
form.submit(submitCallback);
|
||||||
|
|
||||||
var e = $.Event("keydown", { keyCode: 13 });
|
var e = $.Event("keydown", { keyCode: 13 });
|
||||||
e.ctrlKey = true;
|
e.ctrlKey = true;
|
||||||
this.view.keyDownOnCommentBox(e);
|
this.view.keyDownOnCommentBox(e);
|
||||||
|
|
||||||
expect(submitCallback).toHaveBeenCalled();
|
expect(submitCallback).toHaveBeenCalled();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
Loading…
Reference in a new issue