Skip to content
Snippets Groups Projects
Commit 32a45e19 authored by Jim Abramson's avatar Jim Abramson
Browse files

Merge pull request #5227 from edx/jsa/tnl153

allow TAs to select the cohort of new posts.
parents 7593ad3a eef28a4f
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,11 @@ class @DiscussionSpecHelper
window.user = new DiscussionUser({username: "test_user", id: "567", upvoted_ids: []})
DiscussionUtil.setUser(window.user)
@makeTA = () ->
DiscussionUtil.roleIds["Community TA"].push(parseInt(DiscussionUtil.getUser().id))
@makeModerator = () ->
DiscussionUtil.roleIds["Moderator"].push(parseInt(window.user.id))
DiscussionUtil.roleIds["Moderator"].push(parseInt(DiscussionUtil.getUser().id))
@makeAjaxSpy = (fakeAjax) ->
spyOn($, "ajax").andCallFake(
......
......@@ -141,19 +141,26 @@ describe "NewPostView", ->
mode: "tab"
)
expectCohortSelectorVisible = (view, visible) ->
expect(view.$(".js-group-select").is(":visible")).toEqual(visible)
checkVisibility = (view, expectedVisible) =>
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", ->
@view.render()
expectCohortSelectorVisible(@view, false)
checkVisibility(@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()
@view.render()
expectCohortSelectorVisible(@view, true)
expect(@view.$(".js-group-select").prop("disabled")).toEqual(false)
checkVisibility(@view, true)
it "allows the user to make a cohort selection", ->
DiscussionSpecHelper.makeModerator()
@view.render()
expectedGroupId = null
DiscussionSpecHelper.makeAjaxSpy(
(params) -> expect(params.data.group_id).toEqual(expectedGroupId)
......
......@@ -41,7 +41,7 @@ if Backbone?
html
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")
_.map @course_settings.get("cohorts"), (cohort) ->
{value: cohort.id, text: cohort.name, selected: cohort.id==user_cohort_id}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment