diff --git a/common/static/coffee/spec/discussion/view/new_post_view_spec.coffee b/common/static/coffee/spec/discussion/view/new_post_view_spec.coffee index 1f8b9ad627..7cea95b0e3 100644 --- a/common/static/coffee/spec/discussion/view/new_post_view_spec.coffee +++ b/common/static/coffee/spec/discussion/view/new_post_view_spec.coffee @@ -23,6 +23,17 @@ describe "NewPostView", -> + + @@ -92,6 +103,9 @@ describe "NewPostView", -> window.$$course_id = "edX/999/test" spyOn(DiscussionUtil, "makeWmdEditor") @discussion = new Discussion([], {pages: 1}) + + describe "Drop down works correct", -> + beforeEach -> @view = new NewPostView( el: $(".new-post-article"), collection: @discussion, @@ -122,8 +136,6 @@ describe "NewPostView", -> @parent_category_text = "Basic Question Types" @selected_option_text = "Selection From Options" - describe "Drop down works correct", -> - it "completely show parent category and sub-category", -> complete_text = @parent_category_text + " / " + @selected_option_text selected_text_width = @view.getNameWidth(complete_text) @@ -158,3 +170,24 @@ describe "NewPostView", -> @view.$el.find( "ul.topic_menu li[role='menuitem'] > a" )[1].click() dropdown_text = @view.$el.find(".form-topic-drop > a").text() expect(dropdown_text.indexOf("/ span>")).toEqual(-1) + + it "posts to the correct URL", -> + topicId = "test_topic" + spyOn($, "ajax").andCallFake( + (params) -> + expect(params.url.path()).toEqual(DiscussionUtil.urlFor("create_thread", topicId)) + {always: ->} + ) + view = new NewPostView( + el: $(".new-post-article"), + collection: @discussion, + course_settings: new DiscussionCourseSettings({ + allow_anonymous: false, + allow_anonymous_to_peers: false + }), + mode: "inline", + topicId: topicId + ) + view.render() + view.$(".new-post-form").submit() + expect($.ajax).toHaveBeenCalled() diff --git a/common/static/coffee/src/discussion/discussion_module_view.coffee b/common/static/coffee/src/discussion/discussion_module_view.coffee index 11c353677b..811305037b 100644 --- a/common/static/coffee/src/discussion/discussion_module_view.coffee +++ b/common/static/coffee/src/discussion/discussion_module_view.coffee @@ -107,7 +107,8 @@ if Backbone? @newPostView = new NewPostView( el: @newPostForm, collection: @discussion, - course_settings: @course_settings + course_settings: @course_settings, + topicId: discussionId ) @newPostView.render() @discussion.on "add", @addThread diff --git a/common/static/coffee/src/discussion/views/new_post_view.coffee b/common/static/coffee/src/discussion/views/new_post_view.coffee index 24696323bd..cd4d959f3a 100644 --- a/common/static/coffee/src/discussion/views/new_post_view.coffee +++ b/common/static/coffee/src/discussion/views/new_post_view.coffee @@ -7,6 +7,7 @@ if Backbone? throw new Error("invalid mode: " + @mode) @course_settings = options.course_settings @maxNameWidth = 100 + @topicId = options.topicId render: () -> if @mode is "tab"