canvas-lms/spec/apis
Jackson Howe 6a0869a22a Use granular permissions in selective release
Gate the learning object dates api according to new permissions, and
only render the assign to buttons & UI if the appropriate permissions
are present. This commit works by adding a policy called
:manage_assign_to to each learning object model which checks the
appropriate course permissions/ conditions. Then in various parts
throughout the UI, we can simply call `object.grants_right?(user,
:manage_assign_to)` anywhere where we're checking the ability to edit
an existing learning object's assign to settings.

To change a module's assign to settings, require the "Course content -
edit" permission.

For existing learning objects, changing assign to settings requires the
following permissions:
- assignments -> "Manage Assignments and Quizzes - edit"
- quizzes -> "Manage Assignments and Quizzes - edit"
- graded discussions -> "Discussions - moderate" and "Manage Assignments
  and Quizzes - edit"
- ungraded discussions -> "Discussions - moderate" and either a course
  admin enrollment or an enrollment that's not section restricted
- pages -> "Pages - update"

For new learning objects, we require the following permissions on the
object's create page:
- assignments -> "Manage Assignments and Quizzes - add"
- quizzes -> "Manage Assignments and Quizzes - add"
- graded discussions -> "Discussions - create" and "Manage Assignments
  and Quizzes - add"
- ungraded discussions -> "Discussions - create" and either a course
  admin enrollment or an enrollment that's not section restricted
- pages -> "Pages - update"

The "Discussions - moderate" permission can be granted to students, so
if the user does not have an admin enrollment in the course, we verify
that the student's enrollment is not section-restricted before allowing
them to edit a discussion's assign to settings. Thus, students with
"Discussions - moderate" permissions and a section-restricted
enrollment can not use the assign to tray and can no longer
differentiate a discussion by section.

closes LX-1694
flag = differentiated_modules
[fsc-max-nodes=20]
[fsc-timeout=40]

Test plan:
Visit each of the following locations as a teacher and verify that you
can access the "Assign To" UI. Then disable the associated permission
for the teacher and verify that you can no longer access the "Assign
To" UI. Note that you may need to clear your cache and restart Canvas
after toggling permissions.
 - assignments (show, index, edit, create, module items) - note that
   the index can show quiz and graded discussion items, and these
   items' assign to buttons should be gated by their respective
   permissions
 - quizzes (show, index, edit, create, module items)
 - graded discussions (show, index, edit, create, module items)
 - ungraded discussions (show, index, edit, create, module items) -
   test this as a student as well
 - pages (show, index, edit, create, module items)
 - modules (index) - both the menu option and "View Assign To"
   button should be gated

Change-Id: I19bdb24c16a4bc77b993a55be4d9536904c6441f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/348755
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Robin Kuss <rkuss@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Jackson Howe <jackson.howe@instructure.com>
2024-06-04 17:08:18 +00:00
..
html RuboCop: Style/StringLiterals, Style/StringLiteralsInInterpolation 2021-11-25 14:03:06 +00:00
lti rails 7.1: spec/apis 2024-02-26 18:18:53 +00:00
swagger Rubocop for ruby 3.1 2023-06-06 16:44:26 +00:00
v1 Use granular permissions in selective release 2024-06-04 17:08:18 +00:00
api_spec_helper.rb Rubocop for ruby 3.1 2023-06-06 16:44:26 +00:00
auth_spec.rb Allow User to Add Their Name Pronunciation to Profile 2024-05-30 18:12:16 +00:00
error_handling_spec.rb RuboCop: Style/StringLiterals, Style/StringLiteralsInInterpolation 2021-11-25 14:03:06 +00:00
file_uploads_spec_helper.rb Remove verifiers from course files preview 2023-08-31 16:06:37 +00:00
general_api_spec.rb rubocop: Lint/SendWithMixinArgument 2023-06-09 16:04:56 +00:00
locked_examples.rb Add availability columns to pages/discussions/files 2023-12-20 03:21:35 +00:00
user_content_spec.rb Change content translations in lib/user_content 2023-11-22 16:40:12 +00:00