allow TAs to select the cohort of new posts.
TNL-153
This commit is contained in:
@@ -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 moderators to select visibility", ->
|
||||
it "allows TAs to see the cohort selector", ->
|
||||
DiscussionSpecHelper.makeTA()
|
||||
checkVisibility(@view, true)
|
||||
|
||||
it "allows moderators to see the cohort selector", ->
|
||||
DiscussionSpecHelper.makeModerator()
|
||||
checkVisibility(@view, true)
|
||||
|
||||
it "allows the user to make a cohort selection", ->
|
||||
DiscussionSpecHelper.makeModerator()
|
||||
@view.render()
|
||||
expectCohortSelectorVisible(@view, true)
|
||||
expect(@view.$(".js-group-select").prop("disabled")).toEqual(false)
|
||||
|
||||
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}
|
||||
|
||||
Reference in New Issue
Block a user