don't show user avatar path in anonymous peer review api

test plan:
* enable avatars on the root account
* create an assignment with anonymous peer reviews
* as a peer, make a review and a comment on a submission
* as the reviewed student, visit the api index for
 peer reviews, e.g.
 "api/v1/courses/X/assignments/Y/peer_reviews?
  include[]=submission_comments&include[]=user"
* it should not include the user id in the avatar_path

closes #CNVS-24046

Change-Id: I029aa9ebb203d43f546a1bb8e8f7b29160ebdba7
Reviewed-on: https://gerrit.instructure.com/65445
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
This commit is contained in:
James Williams 2015-10-20 10:48:11 -06:00
parent 3d642bb9f4
commit 596086c315
2 changed files with 5 additions and 0 deletions

View File

@ -37,6 +37,9 @@ module Api::V1::SubmissionComment
if submission_comment.grants_right?(@current_user, :read_author)
sc_hash['author'] = user_display_json(submission_comment.author, submission_comment.context)
else
if sc_hash.delete('avatar_path')
sc_hash['avatar_path'] = User.default_avatar_fallback
end
sc_hash.merge!({
author: {},
author_id: nil,

View File

@ -383,6 +383,7 @@ describe PeerReviewsApiController, type: :request do
it 'should not include submission comments user information when anonymous peer reviews' do
@course.root_account.tap{|a| a.enable_service(:avatars)}.save!
@assignment1.update_attribute(:anonymous_peer_reviews, true)
@comment = @submission.add_comment(:author => @student2, :comment => "review comment")
@user = @student1
@ -393,6 +394,7 @@ describe PeerReviewsApiController, type: :request do
"id"=>@assessment_request.id,
"submission_comments" => [{"author_id"=>nil,
"author_name"=>"Anonymous User",
'avatar_path' => User.default_avatar_fallback,
"comment"=>"review comment",
"created_at"=>@comment.created_at.as_json,
"id"=>@comment.id,