Commit bfc475bd by jsa Committed by Zia Fazal

Add topic selection to inline thread editing, fixing errors

Co-Authored-By: Brian Talbot <btalbot@edx.org>

TNL-549
parent 4c1679ac
...@@ -38,13 +38,6 @@ class @DiscussionSpecHelper ...@@ -38,13 +38,6 @@ class @DiscussionSpecHelper
is_cohorted: is_cohorted is_cohorted: is_cohorted
) )
@makeAjaxSpy = (fakeAjax) ->
spyOn($, "ajax").andCallFake(
(params) ->
fakeAjax(params)
{always: ->}
)
@setUnderscoreFixtures = -> @setUnderscoreFixtures = ->
for templateName in ['thread-show'] for templateName in ['thread-show']
templateFixture = readFixtures('templates/discussion/' + templateName + '.underscore') templateFixture = readFixtures('templates/discussion/' + templateName + '.underscore')
......
...@@ -113,36 +113,58 @@ ...@@ -113,36 +113,58 @@
}); });
}); });
it('can save new data correctly', function() { testUpdate = function(view, thread) {
var view;
spyOn($, 'ajax').andCallFake(function(params) { spyOn($, 'ajax').andCallFake(function(params) {
expect(params.url.path()).toEqual(DiscussionUtil.urlFor('update_thread', 'dummy_id')); expect(params.url.path()).toEqual(DiscussionUtil.urlFor('update_thread', 'dummy_id'));
if (view.isTabMode()) {
// TODO remove the tabMode condition, depends on #5554 / TNL-606
expect(params.data.thread_type).toBe('discussion'); expect(params.data.thread_type).toBe('discussion');
expect(params.data.commentable_id).toBe('topic'); }
expect(params.data.title).toBe('new_title'); expect(params.data.commentable_id).toBe('other_topic');
expect(params.data.title).toBe('changed thread title');
params.success(); params.success();
return {always: function() {}}; return {always: function() {}};
}); });
this.createEditView(); view.$el.find('a.topic-title')[1].click(); // set new topic
this.view.$el.find('a.topic-title').first().click(); // set new topic view.$('.edit-post-title').val('changed thread title'); // set new title
this.view.$('.edit-post-title').val('new_title'); // set new title view.$("label[for$='post-type-discussion']").click(); // set new thread type
this.view.$("label[for$='post-type-discussion']").click(); // set new thread type view.$('.post-update').click();
this.view.$('.post-update').click();
expect($.ajax).toHaveBeenCalled(); expect($.ajax).toHaveBeenCalled();
expect(this.thread.get('title')).toBe('new_title'); expect(thread.get('title')).toBe('changed thread title');
expect(this.thread.get('commentable_id')).toBe('topic'); if (view.isTabMode()) {
expect(this.thread.get('thread_type')).toBe('discussion'); // TODO remove the tabMode condition, depends on #5554 / TNL-606
expect(this.thread.get('courseware_title')).toBe('Topic'); expect(thread.get('thread_type')).toBe('discussion');
}
expect(thread.get('commentable_id')).toBe('other_topic');
expect(thread.get('courseware_title')).toBe('Other Topic');
expect(view.$('.edit-post-title')).toHaveValue('');
expect(view.$('.wmd-preview p')).toHaveText('');
}
expect(this.view.$('.edit-post-title')).toHaveValue(''); it('can save new data correctly in tab mode', function() {
expect(this.view.$('.wmd-preview p')).toHaveText(''); this.createEditView();
testUpdate(this.view, this.thread);
}); });
it('can close the view', function() { it('can save new data correctly in inline mode', function() {
this.createEditView(); this.createEditView({"mode": "inline"});
this.view.$('.post-cancel').click(); testUpdate(this.view, this.thread);
});
testCancel = function(view) {
view.$('.post-cancel').click();
expect($('.edit-post-form')).not.toExist(); expect($('.edit-post-form')).not.toExist();
}
it('can close the view in tab mode', function() {
this.createEditView();
testCancel(this.view);
});
it('can close the view in inline mode', function() {
this.createEditView({"mode": "inline"});
testCancel(this.view);
}); });
}); });
}).call(this); }).call(this);
...@@ -265,7 +265,7 @@ def single_thread(request, course_id, discussion_id, thread_id): ...@@ -265,7 +265,7 @@ def single_thread(request, course_id, discussion_id, thread_id):
nr_transaction = newrelic.agent.current_transaction() nr_transaction = newrelic.agent.current_transaction()
course = get_course_with_access(request.user, 'load_forum', course_key) course = get_course_with_access(request.user, 'load_forum', course_key)
course_settings = make_course_settings(course, include_category_map=True) course_settings = make_course_settings(course)
cc_user = cc.User.from_django_user(request.user) cc_user = cc.User.from_django_user(request.user)
user_info = cc_user.to_dict() user_info = cc_user.to_dict()
is_moderator = cached_has_permission(request.user, "see_all_cohorts", course_key) is_moderator = cached_has_permission(request.user, "see_all_cohorts", course_key)
......
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