Commit c1af2f8a by jmclaus Committed by Zia Fazal

TNL-172: Change type of a previously posted post. IMPORTANT: this commit depends…

TNL-172: Change type of a previously posted post. IMPORTANT: this commit depends on commit 774887b in cs_comments_service.
parent 5cae612c
......@@ -117,6 +117,7 @@
var view;
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('topic');
expect(params.data.title).toBe('new_title');
params.success();
......@@ -125,11 +126,13 @@
this.createEditView();
this.view.$el.find('a.topic-title').first().click(); // set new topic
this.view.$('.edit-post-title').val('new_title'); // set new title
this.view.$("label[for$='post-type-discussion']").click(); // set new thread type
this.view.$('.post-update').click();
expect($.ajax).toHaveBeenCalled();
expect(this.thread.get('title')).toBe('new_title');
expect(this.thread.get('commentable_id')).toBe('topic');
expect(this.thread.get('thread_type')).toBe('discussion');
expect(this.thread.get('courseware_title')).toBe('Topic');
expect(this.view.$('.edit-post-title')).toHaveValue('');
......
......@@ -309,7 +309,7 @@ describe "NewPostView", ->
eventSpy = jasmine.createSpy('eventSpy')
view.listenTo(view, "newPost:cancel", eventSpy)
view.$(".post-errors").html("<li class='post-error'>Title can't be empty</li>")
view.$("#tab-post-type-discussion").click()
view.$("label[for$='post-type-discussion']").click()
view.$(".js-post-title").val("Test Title")
view.$(".js-post-body textarea").val("Test body")
view.$(".wmd-preview p").html("Test body")
......@@ -321,13 +321,14 @@ describe "NewPostView", ->
view.$(".cancel").click()
expect(eventSpy).toHaveBeenCalled()
expect(view.$(".post-errors").html()).toEqual("");
expect($("##{mode}-post-type-question").prop("checked")).toBe(true)
expect($("##{mode}-post-type-discussion").prop("checked")).toBe(false)
if mode == "tab"
expect($("input[id$='post-type-question']")).toBeChecked()
expect($("input[id$='post-type-discussion']")).not.toBeChecked()
expect(view.$(".js-post-title").val()).toEqual("");
expect(view.$(".js-post-body textarea").val()).toEqual("");
expect(view.$(".js-follow").prop("checked")).toBe(true)
expect(view.$(".js-anon").prop("checked")).toBe(false)
expect(view.$(".js-anon-peers").prop("checked")).toBe(false)
expect(view.$(".js-follow")).toBeChecked()
expect(view.$(".js-anon")).not.toBeChecked()
expect(view.$(".js-anon-peers")).not.toBeChecked()
if mode == "tab"
expect(view.$(".js-selected-topic").text()).toEqual("General")
......
......@@ -23,6 +23,8 @@ if Backbone?
$('.group-selector-wrapper').hide()
@addField(threadTypeTemplate({form_id: _.uniqueId("form-")}));
if @isTabMode()
threadTypeTemplate = _.template($("#thread-type-template").html());
@addField(threadTypeTemplate({form_id: _.uniqueId("form-")}));
@topicView = new DiscussionTopicMenuView {
topicId: @topicId
course_settings: @course_settings,
......
......@@ -1108,7 +1108,7 @@ class UpdateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockReq
"user_id": str(self.student.id),
"closed": False,
})
request = RequestFactory().post("dummy_url", {"body": text, "title": text, "commentable_id": "test_commentable"})
request = RequestFactory().post("dummy_url", {"body": text, "title": text, "thread_type": "question", "commentable_id": "test_commentable"})
request.user = self.student
request.view_name = "update_thread"
response = views.update_thread(request, course_id=self.course.id.to_deprecated_string(), thread_id="dummy_thread_id")
......@@ -1117,6 +1117,7 @@ class UpdateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockReq
self.assertTrue(mock_request.called)
self.assertEqual(mock_request.call_args[1]["data"]["body"], text)
self.assertEqual(mock_request.call_args[1]["data"]["title"], text)
self.assertEqual(mock_request.call_args[1]["data"]["thread_type"], "question")
self.assertEqual(mock_request.call_args[1]["data"]["commentable_id"], "test_commentable")
......
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