canvas-lms/spec/serializers
Evan Battaglia ba1495a151 Use a Group's Course for LTI var expansions
Currently, if a tool is launched in the context of a Group, all
all Course-related LTI variable expansions will not be expanded, even if
the Group's context is a Course.

This commit:
1. Expands all COURSE_GUARD, TERM_*_GUARD, ENROLLMENT_GUARD,
  and STUDENT_ASSIGNMENT_GUARD lti variable expansions, which previously
  required a Course context, to work with a Group with a Course context.
  Namely, if @context is a course, they will use @context.context as the
  Course. Examples: Canvas.course.{id, name, startAt...}
2. Expands ROLES_GUARD permissions to work when context is a Group.
   These previously only worked when context was a Course or Group. For
   the first two (com.Instructure.membership.roles and
   Canvas.membership.roles) we simply use the enrollments from the
   Group's Account (or Group's Course and Account, if Group has a
   course). For `Canvas.membership.permissions` we check grants_right?
   directly on the @context (Group)
3. Also fixes the following expansions to be consistent for groups (give
   account, not root account):
   - Canvas.account.id
   - Canvas.account.name
   - Canvas.account.sisSourceId
4. Incidentally, due to the change of helper functions, the following
   expansions were also affected in that they now include roles from the
   Course if the @context is a Group with a Course context:
   - Membership.role
   - Canvas.xuser.allRoles
   - com.instructure.User.allRoles

See comments in ticket for full list of expansions affected.

Test plan:
- create a course in a subaccount
- make a Group in that course
- make an LTI tool in the account level that has variable expansions in
  custom fields -- at least one for each of the types of changes
  enumerated above. The tool should have the editor_button placement. (I
  couldn't seen to find any other placements shown in a page with a
  Group context...)
- launch the tool and check the custom variable expansions.
- turn the lti_variable_expansions_use_group_course_as_course flag off
  and relaunch the tool. The variable expansions should be as they were
  before this commit (likely unexpanded).

closes INTEROP-8737
flag = lti_variable_expansions_use_group_course_as_course

[fsc-max-nodes=18]
[fsc-timeout=40]

Change-Id: I4fffc6b5f91f8578a1e8b13907523e1372050f7f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/352964
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Ryan Hawkins <ryan.hawkins@instructure.com>
QA-Review: Paul Gray <paul.gray@instructure.com>
Product-Review: Alexis Nast <alexis.nast@instructure.com>
2024-07-31 23:28:41 +00:00
..
canvas bundle update rubocop 2024-06-11 17:11:55 +00:00
live_events Rubocop for ruby 3.1 2023-06-06 16:44:26 +00:00
lti Use a Group's Course for LTI var expansions 2024-07-31 23:28:41 +00:00
quizzes Use granular permissions in selective release 2024-06-04 17:08:18 +00:00
quizzes_next bump rubocop gems and apply changes 2023-08-07 20:13:35 +00:00
attachment_serializer_spec.rb bump rubocop gems and apply changes 2023-08-07 20:13:35 +00:00
late_policy_serializer_spec.rb RuboCop: Style/StringLiterals, Style/StringLiteralsInInterpolation 2021-11-25 14:03:06 +00:00
progress_serializer_spec.rb bump rubocop gems and apply changes 2023-08-07 20:13:35 +00:00