fixing commenting

Added jamisne tests for comments

Added 2 jasmine tests for fixing commenting

Bugfix: #4005 added changelog entry
This commit is contained in:
PallaviTS 2013-08-31 12:56:53 +05:30 committed by Jonne Haß
parent 5a821efa18
commit 5caa46cc83
3 changed files with 37 additions and 17 deletions

View file

@ -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)
* 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 commenting upon submission fail [#4005] (https://github.com/diaspora/diaspora/issues/4005)
## Features
* Add oEmbed content to the mobile view [#4343](https://github.com/diaspora/diaspora/pull/4353)

View file

@ -13,11 +13,17 @@ app.collections.Comments = Backbone.Collection.extend({
var self = this
var comment = new app.models.Comment({text: text })
, deferred = comment.save({}, {url : self.url()})
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
}

View file

@ -39,7 +39,19 @@ describe("app.views.CommentStream", function(){
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");
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() {