Commit c3845de7 by Greg Price

Fix bug in inline discussion post creation

Commit 994ccd11 contained a bug that caused new posts created via the
courseware interface to not get posted to the correct topic. They would
appear to work but would actually be posted to the "undefined" topic.
This has now been fixed.

JIRA: FOR-154
parent 69e20595
...@@ -23,6 +23,17 @@ describe "NewPostView", -> ...@@ -23,6 +23,17 @@ describe "NewPostView", ->
</div> </div>
</script> </script>
<script aria-hidden="true" type="text/template" id="new-post-inline-template">
<div class="inner-wrapper">
<div class="new-post-form-errors">
</div>
<form class="new-post-form">
<%= editor_html %>
<%= options_html %>
</form>
</div>
</script>
<script aria-hidden="true" type="text/template" id="new-post-menu-entry-template"> <script aria-hidden="true" type="text/template" id="new-post-menu-entry-template">
<li role="menuitem"><a href="#" class="topic" data-discussion_id="<%- id %>" aria-describedby="topic-name-span-<%- id %>" cohorted="<%- is_cohorted %>"><%- text %></a></li> <li role="menuitem"><a href="#" class="topic" data-discussion_id="<%- id %>" aria-describedby="topic-name-span-<%- id %>" cohorted="<%- is_cohorted %>"><%- text %></a></li>
</script> </script>
...@@ -92,6 +103,9 @@ describe "NewPostView", -> ...@@ -92,6 +103,9 @@ describe "NewPostView", ->
window.$$course_id = "edX/999/test" window.$$course_id = "edX/999/test"
spyOn(DiscussionUtil, "makeWmdEditor") spyOn(DiscussionUtil, "makeWmdEditor")
@discussion = new Discussion([], {pages: 1}) @discussion = new Discussion([], {pages: 1})
describe "Drop down works correct", ->
beforeEach ->
@view = new NewPostView( @view = new NewPostView(
el: $(".new-post-article"), el: $(".new-post-article"),
collection: @discussion, collection: @discussion,
...@@ -122,8 +136,6 @@ describe "NewPostView", -> ...@@ -122,8 +136,6 @@ describe "NewPostView", ->
@parent_category_text = "Basic Question Types" @parent_category_text = "Basic Question Types"
@selected_option_text = "Selection From Options" @selected_option_text = "Selection From Options"
describe "Drop down works correct", ->
it "completely show parent category and sub-category", -> it "completely show parent category and sub-category", ->
complete_text = @parent_category_text + " / " + @selected_option_text complete_text = @parent_category_text + " / " + @selected_option_text
selected_text_width = @view.getNameWidth(complete_text) selected_text_width = @view.getNameWidth(complete_text)
...@@ -158,3 +170,24 @@ describe "NewPostView", -> ...@@ -158,3 +170,24 @@ describe "NewPostView", ->
@view.$el.find( "ul.topic_menu li[role='menuitem'] > a" )[1].click() @view.$el.find( "ul.topic_menu li[role='menuitem'] > a" )[1].click()
dropdown_text = @view.$el.find(".form-topic-drop > a").text() dropdown_text = @view.$el.find(".form-topic-drop > a").text()
expect(dropdown_text.indexOf("/ span>")).toEqual(-1) 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()
...@@ -107,7 +107,8 @@ if Backbone? ...@@ -107,7 +107,8 @@ if Backbone?
@newPostView = new NewPostView( @newPostView = new NewPostView(
el: @newPostForm, el: @newPostForm,
collection: @discussion, collection: @discussion,
course_settings: @course_settings course_settings: @course_settings,
topicId: discussionId
) )
@newPostView.render() @newPostView.render()
@discussion.on "add", @addThread @discussion.on "add", @addThread
......
...@@ -7,6 +7,7 @@ if Backbone? ...@@ -7,6 +7,7 @@ if Backbone?
throw new Error("invalid mode: " + @mode) throw new Error("invalid mode: " + @mode)
@course_settings = options.course_settings @course_settings = options.course_settings
@maxNameWidth = 100 @maxNameWidth = 100
@topicId = options.topicId
render: () -> render: () ->
if @mode is "tab" if @mode is "tab"
......
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