Commit f1df9a10 by Waqas Khalid

Fix anonymous posts appear are labeled with the logged in user's role

FOR-156
parent 9cf082e7
......@@ -2,6 +2,22 @@ describe 'All Content', ->
beforeEach ->
DiscussionSpecHelper.setUpGlobals()
describe 'Staff and TA Content', ->
beforeEach ->
DiscussionUtil.loadRoles({"Moderator": [567], "Administrator": [567], "Community TA": [567]})
it 'anonymous thread should not include login role label', ->
anon_content = new Content
anon_content.initialize
expect(anon_content.get 'staff_authored').toBe false
expect(anon_content.get 'community_ta_authored').toBe false
it 'general thread should include login role label', ->
anon_content = new Content { user_id: '567' }
anon_content.initialize
expect(anon_content.get 'staff_authored').toBe true
expect(anon_content.get 'community_ta_authored').toBe true
describe 'Content', ->
beforeEach ->
@content = new Content {
......
......@@ -54,8 +54,12 @@ if Backbone?
initialize: ->
Content.addContent @id, @
userId = @get('user_id')
@set('staff_authored', DiscussionUtil.isStaff(userId))
@set('community_ta_authored', DiscussionUtil.isTA(userId))
if userId?
@set('staff_authored', DiscussionUtil.isStaff(userId))
@set('community_ta_authored', DiscussionUtil.isTA(userId))
else
@set('staff_authored', false)
@set('community_ta_authored', false)
if Content.getInfo(@id)
@updateInfo(Content.getInfo(@id))
@set 'user_url', DiscussionUtil.urlFor('user_profile', userId)
......
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