Commit 2dcb8f81 by Brian Jacobel

Fix issue where duplicate toolbars would be displayed above discussion forum comments while posting

TNL-5105
parent 91c1049b
......@@ -309,7 +309,7 @@
var appended_id, editor, elem, id, imageUploadUrl, placeholder, _processor;
elem = $local('.' + cls_identifier);
placeholder = elem.data('placeholder');
id = elem.attr('data-id');
id = elem.data('id');
appended_id = '-' + cls_identifier + '-' + id;
imageUploadUrl = this.urlFor('upload');
_processor = function(self) {
......
......@@ -72,7 +72,7 @@
container = $('.discussion-module');
}
templateData = _.extend(this.model.toJSON(), {
wmdId: (_ref = this.model.id) !== null ? _ref : (new Date()).getTime(),
wmdId: typeof(this.model.id) !== 'undefined' ? this.model.id : (new Date()).getTime(),
create_sub_comment: container.data('user-create-subcomment'),
readOnly: this.readOnly
});
......
/* globals DiscussionSpecHelper, ResponseCommentView, Thread, ThreadResponseView, ThreadResponseShowView */
/* globals DiscussionSpecHelper, ResponseCommentView, Thread, ThreadResponseView, ThreadResponseShowView, _ */
(function() {
'use strict';
describe('ThreadResponseView', function() {
......@@ -89,6 +89,25 @@
return expect(this.view.$('.action-show-comments')).not.toBeVisible();
}
);
it('calls renderTemplate with a temporary id if the model lacks one', function() {
this.view = new ThreadResponseView({
model: this.response,
el: $('#fixture-element'),
collapseComments: true
});
spyOn(_, 'extend').and.callThrough();
spyOn(window, 'Date').and.callFake(function() {
return {
getTime: function() {
return 1;
}
};
});
this.view.render();
expect(_.extend).toHaveBeenCalledWith(jasmine.any(Object), jasmine.objectContaining({
wmdId: 1
}));
});
it('populates commentViews and binds events', function() {
this.view.createEditView();
spyOn(this.view, 'cancelEdit');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment