Fix to_do_list_presenter when there are peer reviews

fixes ADMIN-1564

test plan:
  - have a course with a peer reviewed assignment due in the near
    future.
  - have the reviewee submit the assignment
  - load the course page as the reviewer
  > expect the page to load w/o rails throwing an exception
  > expect the peer review item to appear in the to do sidebar

Change-Id: I0704c6da01949e94396aa967db5e0e348b109e22
Reviewed-on: https://gerrit.instructure.com/169254
Tested-by: Jenkins
Reviewed-by: Carl Kibler <ckibler@instructure.com>
QA-Review: Jeremy Stanley <jeremy@instructure.com>
Product-Review: KC Naegle <knaegle@instructure.com>
This commit is contained in:
Ed Schiebel 2018-10-22 16:01:17 -04:00
parent ef82ecbaa7
commit 8819c50832
2 changed files with 30 additions and 2 deletions

View File

@ -32,6 +32,7 @@ class ToDoListPresenter
@needs_submitting = assignments_needing(:submitting, include_ungraded: true)
@needs_submitting += ungraded_quizzes_needing_submitting
@needs_submitting.sort_by! { |a| a.due_at || a.updated_at }
assessment_requests = user.submissions_needing_peer_review(contexts: contexts, limit: ASSIGNMENT_LIMIT)
@needs_reviewing = assessment_requests.map do |ar|
AssessmentRequestPresenter.new(view, ar, user) if ar.asset.assignment.published?
@ -213,8 +214,7 @@ class ToDoListPresenter
end
class AssessmentRequestPresenter
delegate :context_name, to: :assignment_presenter
delegate :short_context_name, to: :assignment_presenter
delegate :context, :context_name, :short_context_name, to: :assignment_presenter
attr_reader :assignment
def initialize(view, assessment_request, user)

View File

@ -52,9 +52,11 @@ describe 'ToDoListPresenter' do
let(:course1) { Course.create! }
let(:course2) { Course.create! }
let(:student) { user_with_multiple_enrollments('StudentEnrollment') }
let(:student2) { user_with_multiple_enrollments('StudentEnrollment') }
let(:grader) { user_with_multiple_enrollments('TeacherEnrollment') }
let(:final_grader) { user_with_multiple_enrollments('TeacherEnrollment') }
def user_with_multiple_enrollments(enrollment_type)
result = course_with_user(enrollment_type, course: course1, active_all: true).user
course_with_user(enrollment_type, user: result, course: course2, active_all: true).user
@ -105,4 +107,30 @@ describe 'ToDoListPresenter' do
expect(presenter.needs_moderation.map(&:title)).to contain_exactly('assignment1')
end
end
context "peer reviews" do
let(:course1) { Course.create! }
let(:reviewer) { course_with_user('StudentEnrollment', course: course1, active_all: true).user }
let(:reviewee) { course_with_user('StudentEnrollment', course: course1, active_all: true).user }
before :each do
course1.offer!
assignment = Assignment.create({
context: course1,
title: 'assignment3',
submission_types: 'online_text_entry',
due_at: 1.day.from_now,
peer_reviews: true
})
assignment.publish
assessment = assignment.assign_peer_review(reviewer, reviewee)
assignment.submit_homework(reviewee, body: 'you say potato...')
end
it "does not blow up" do
presenter = ToDoListPresenter.new(nil, reviewer, [course1])
# basically checking that ToDoListPresenter.initialize didn't raise and error
expect(presenter).not_to be_nil
end
end
end