Commit 9ba03c8a by Waqas Khalid

Post with the discussion id containing dots uneditable

When user try to edit the post under dicussion whose
id contains dots it doesn't allow user to edit taht
post.

TNL-607
parent 9d575990
......@@ -26,16 +26,16 @@
};
});
testUpdate = function(view, thread) {
testUpdate = function(view, thread, newTopicId, newTopicName) {
spyOn($, 'ajax').andCallFake(function(params) {
expect(params.url.path()).toEqual(DiscussionUtil.urlFor('update_thread', 'dummy_id'));
expect(params.data.thread_type).toBe('discussion');
expect(params.data.commentable_id).toBe('other_topic');
expect(params.data.commentable_id).toBe(newTopicId);
expect(params.data.title).toBe('changed thread title');
params.success();
return {always: function() {}};
});
view.$el.find('a.topic-title')[1].click(); // set new topic
view.$el.find('a.topic-title[data-discussion-id="'+newTopicId+'"]').click(); // set new topic
view.$('.edit-post-title').val('changed thread title'); // set new title
view.$("label[for$='post-type-discussion']").click(); // set new thread type
view.$('.post-update').click();
......@@ -43,20 +43,20 @@
expect(thread.get('title')).toBe('changed thread title');
expect(thread.get('thread_type')).toBe('discussion');
expect(thread.get('commentable_id')).toBe('other_topic');
expect(thread.get('courseware_title')).toBe('Other Topic');
expect(thread.get('commentable_id')).toBe(newTopicId);
expect(thread.get('courseware_title')).toBe(newTopicName);
expect(view.$('.edit-post-title')).toHaveValue('');
expect(view.$('.wmd-preview p')).toHaveText('');
};
it('can save new data correctly in tab mode', function() {
this.createEditView();
testUpdate(this.view, this.thread);
testUpdate(this.view, this.thread, 'other_topic', 'Other Topic');
});
it('can save new data correctly in inline mode', function() {
this.createEditView({"mode": "inline"});
testUpdate(this.view, this.thread);
testUpdate(this.view, this.thread, 'other_topic', 'Other Topic');
});
testCancel = function(view) {
......@@ -73,5 +73,45 @@
this.createEditView({"mode": "inline"});
testCancel(this.view);
});
describe('renderComments', function() {
beforeEach(function() {
this.course_settings = new DiscussionCourseSettings({
'category_map': {
'children': ['Topic', 'General', 'Basic Question'],
'entries': {
'Topic': {
'is_cohorted': true,
'id': 'topic'
},
"General": {
"sort_key": "General",
"is_cohorted": false,
"id": "6.00.1x_General"
},
"Basic Question": {
"is_cohorted": false,
"id": "6>00'1x\"Basic_Question"
}
}
},
'is_cohorted': true
});
});
it('can save new data correctly for current discussion id without dots', function () {
this.createEditView({topicId: "topic"});
testUpdate(this.view, this.thread, "6.00.1x_General", "General");
});
it('can save new data correctly for current discussion id with dots', function () {
this.createEditView({topicId: "6.00.1x_General"});
testUpdate(this.view, this.thread, "6>00'1x\"Basic_Question", "Basic Question");
});
it('can save new data correctly for current discussion id with special characters', function () {
this.createEditView({topicId: "6>00'1x\"Basic_Question"});
testUpdate(this.view, this.thread, "6.00.1x_General", "General");
});
});
});
}).call(this);
......@@ -40,7 +40,7 @@
this.selectedTopic = this.$('.js-selected-topic');
this.hideTopicDropdown();
if (this.getCurrentTopicId()) {
this.setTopic(this.$('a.topic-title').filter('[data-discussion-id=' + this.getCurrentTopicId() + ']'));
this.setTopic(this.$('a.topic-title').filter('[data-discussion-id="' + this.getCurrentTopicId() + '"]'));
} else {
this.setTopic(this.$('a.topic-title').first());
}
......
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