Fix showing todos to observer on dashboard

Fixes a regression that prevented observers from seeing the 'coming
up' list on the classic dashboard.

fixes LS-2812
flag = none

Test plan:
 - Create an observer linked to a student in a classic course with
   (at least) 1 upcoming assignment
 - Visit the classic dashboard as the observer
 - Expect to see the upcoming assignment under 'coming up' sidebar
 - Visit the classic dashboard as the student
 - Expect to see the assignment in the same place
 - Visit the k5 dashboard as an observer of a k5 student and switch to
   the schedule tab
 - Expect to see the student's assignments in the planner

Change-Id: If03b864a558727ba1185c7f126677496adbe8940
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277401
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Nate Armstrong <narmstrong@instructure.com>
QA-Review: Nate Armstrong <narmstrong@instructure.com>
Product-Review: Jackson Howe <jackson.howe@instructure.com>
This commit is contained in:
Jackson Howe 2021-11-03 16:52:02 -06:00
parent 00d2af090d
commit 4f01df0ecc
3 changed files with 33 additions and 3 deletions

View File

@ -1218,7 +1218,8 @@ module ApplicationHelper
end
def planner_enabled?
!!(@current_user&.has_student_enrollment?) || (Account.site_admin.feature_enabled?(:k5_parent_support) && @current_user&.roles(@domain_root_account)&.include?('observer'))
!!(@current_user&.has_student_enrollment?) ||
(Account.site_admin.feature_enabled?(:k5_parent_support) && @current_user&.roles(@domain_root_account)&.include?('observer') && k5_user?)
end
def will_paginate(collection, options = {})

View File

@ -853,9 +853,16 @@ describe ApplicationHelper do
expect(planner_enabled?).to be true
end
it "returns true for the observer" do
it "returns false for the observer if not k5_user" do
allow(helper).to receive(:k5_user?).and_return(false)
@current_user = @observer
expect(planner_enabled?).to be true
expect(helper.planner_enabled?).to be false
end
it "returns true for the observer if k5_user" do
allow(helper).to receive(:k5_user?).and_return(true)
@current_user = @observer
expect(helper.planner_enabled?).to be true
end
it "still returns false for a teacher" do

View File

@ -98,4 +98,26 @@ describe "dashboard" do
expect(f("#content")).not_to contain_css('#planner-todosidebar-item-list')
end
end
context "as an observer" do
before :once do
Account.site_admin.enable_feature!(:k5_parent_support)
course_with_student(active_all: true)
@student = @user
@observer = user_factory(active_all: true)
@course.enroll_user(@observer, "ObserverEnrollment", { associated_user_id: @student.id })
assignment_model(due_at: 2.days.from_now, course: @course, submission_types: 'online_text_entry', name: 'Todo for observer')
end
before :each do
user_session(@observer)
end
it "renders classic todos for observers, even with planner enabled" do
get "/"
wait_for_ajaximations
expect(f('.right-side-list.events .event-details__title')).to include_text('Todo for observer')
end
end
end