Commit 32a45e19 by Jim Abramson

Merge pull request #5227 from edx/jsa/tnl153

allow TAs to select the cohort of new posts.
parents 7593ad3a eef28a4f
...@@ -6,8 +6,11 @@ class @DiscussionSpecHelper ...@@ -6,8 +6,11 @@ class @DiscussionSpecHelper
window.user = new DiscussionUser({username: "test_user", id: "567", upvoted_ids: []}) window.user = new DiscussionUser({username: "test_user", id: "567", upvoted_ids: []})
DiscussionUtil.setUser(window.user) DiscussionUtil.setUser(window.user)
@makeTA = () ->
DiscussionUtil.roleIds["Community TA"].push(parseInt(DiscussionUtil.getUser().id))
@makeModerator = () -> @makeModerator = () ->
DiscussionUtil.roleIds["Moderator"].push(parseInt(window.user.id)) DiscussionUtil.roleIds["Moderator"].push(parseInt(DiscussionUtil.getUser().id))
@makeAjaxSpy = (fakeAjax) -> @makeAjaxSpy = (fakeAjax) ->
spyOn($, "ajax").andCallFake( spyOn($, "ajax").andCallFake(
......
...@@ -141,19 +141,26 @@ describe "NewPostView", -> ...@@ -141,19 +141,26 @@ describe "NewPostView", ->
mode: "tab" mode: "tab"
) )
expectCohortSelectorVisible = (view, visible) -> checkVisibility = (view, expectedVisible) =>
expect(view.$(".js-group-select").is(":visible")).toEqual(visible) view.render()
expect(view.$(".js-group-select").is(":visible")).toEqual(expectedVisible)
if expectedVisible
expect(view.$(".js-group-select").prop("disabled")).toEqual(false)
it "is not visible to students", -> it "is not visible to students", ->
@view.render() checkVisibility(@view, false)
expectCohortSelectorVisible(@view, false)
it "allows TAs to see the cohort selector", ->
DiscussionSpecHelper.makeTA()
checkVisibility(@view, true)
it "allows moderators to select visibility", -> it "allows moderators to see the cohort selector", ->
DiscussionSpecHelper.makeModerator() DiscussionSpecHelper.makeModerator()
@view.render() checkVisibility(@view, true)
expectCohortSelectorVisible(@view, true)
expect(@view.$(".js-group-select").prop("disabled")).toEqual(false)
it "allows the user to make a cohort selection", ->
DiscussionSpecHelper.makeModerator()
@view.render()
expectedGroupId = null expectedGroupId = null
DiscussionSpecHelper.makeAjaxSpy( DiscussionSpecHelper.makeAjaxSpy(
(params) -> expect(params.data.group_id).toEqual(expectedGroupId) (params) -> expect(params.data.group_id).toEqual(expectedGroupId)
......
...@@ -41,7 +41,7 @@ if Backbone? ...@@ -41,7 +41,7 @@ if Backbone?
html html
getCohortOptions: () -> getCohortOptions: () ->
if @course_settings.get("is_cohorted") and DiscussionUtil.isStaff() if @course_settings.get("is_cohorted") and DiscussionUtil.isPrivilegedUser()
user_cohort_id = $("#discussion-container").data("user-cohort-id") user_cohort_id = $("#discussion-container").data("user-cohort-id")
_.map @course_settings.get("cohorts"), (cohort) -> _.map @course_settings.get("cohorts"), (cohort) ->
{value: cohort.id, text: cohort.name, selected: cohort.id==user_cohort_id} {value: cohort.id, text: cohort.name, selected: cohort.id==user_cohort_id}
......
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