canvas-lms/spec
Matthew Lemon 40fe720649 respect notification preference overrides
Allows course context notification preference overrides to actually take
effect when creating notifications for a user.

fixes KNO-402
flag=notification_granular_course_preferences

/ ---- ---- \
| Test Plan |
\ ---- ---- /

- Run the following migration
  bundle exec rake db:migrate:up VERSION=20200420211742
- Create two courses and add a student and a teacher to it
- configure a communication channel for the student
- As the student create a notification preference override for
  announcments with an immediate frequency for the first course
  - This can be done through graphiql using the following mutation

```
mutation MyMutation {
  __typename
  updateNotificationPreferences(
    input: {
      contextType: Course,
      communicationChannelId: <communication_channel_id>,
      courseId: <course_id>,
      frequency: immediate,
      notificationCategory: Announcement
    }
  ) {
    course {
      _id
      notificationPreferences {
        channels {
          _id
          path
          pathType
          notificationPolicies {
            communicationChannelId
            frequency
            notification {
              category
              categoryDisplayName
              name
            }
          }
          notificationPolicyOverrides(
            contextType: Course,
            courseId: <course_id>
          ) {
            communicationChannelId
            frequency
            notification {
              category
              categoryDisplayName
              name
            }
          }
        }
      }
      notificationPreferencesEnabled
    }
  }
}
```

- As the student navigate to /profile/communication and set all your
  Announcement policies to 'weekly'
- As the teacher navigate to the SECOND course and create an
  announcement
- Navigate to /users/<student_id>/messages and note that the
  announcement notification should not exist
- In a rails console check that the DelayedMessage was created
  n = Notification.where(category: 'Announcement').first
  delayed_messages = DelayedMessage.where(
    notification_id: n.id,
    communication_channel_id: <channel_id>
  )
  - The delayed_messages array should contain the notification for the
    announcment with a 'weekly' frequency

- As the teacher navigate to the FIRST course and create an announcement
- Navigate to /users/<student_id>/messages and note that the
  announcement notification should exist
- In a rails console validate that the DelayedMessage was not created
  using similar steps as detailed above

- Now as the student set your override policy to 'daily' using the same
  mutation provided above but changing the frequency
- navigate to /profile/communication and set all your Announcement
  policies to 'immediately'
- Run the same tests as above but now validate that an immediate message
  is created for the second course when an announcment is created and no
  delayed message is created
- Also verify that a delayed message with a 'daily' frequency is created
  for the first course when an announcement is created and no immediate
  message is created
- phew, that was a doozy of a test plan!

Change-Id: Idb5e95bf13762472c3fdd7aceef200a17f5cd9a0
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/234804
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Ahmad Amireh <ahmad@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2020-05-04 19:06:04 +00:00
..
apis add conference ui to calendar details page 2020-04-30 18:06:11 +00:00
coffeescripts Revert "Add new font to RCE" 2020-05-02 00:19:16 +00:00
contracts spec: add Catalog consumer to Pact contract test suite 2020-04-20 20:38:18 +00:00
controllers Do not show Mobile QR tab when IMP is not present 2020-05-02 00:08:27 +00:00
factories rails 6: s/update_attributes/update/g 2020-01-09 20:56:35 +00:00
fixtures show notes recording formats to students for bbb 2020-04-13 18:03:33 +00:00
formatters use parallel_tests for more parallelization 2020-03-30 21:38:47 +00:00
gem_integration/canvas_connect
graphql spec: clear other notifications before spec 2020-05-04 13:49:12 +00:00
helpers Configurable outcomes service protocol 2020-04-23 22:34:42 +00:00
initializers fix find_in_batches problem 2020-05-03 15:47:15 +00:00
instfs/selenium remove all the legacy RCE code 2019-04-04 18:19:12 +00:00
integration move unbounded user preference data to separate table 2020-03-02 20:10:32 +00:00
javascripts add ui for adding conference from calendar entry 2020-04-30 18:06:01 +00:00
lib respect notification preference overrides 2020-05-04 19:06:04 +00:00
manual_seeding
messages Use custom account name for global announcements 2020-02-25 20:45:23 +00:00
middleware
migrations squash old migrations, p23 2020-05-01 18:49:51 +00:00
models move SMS whitelist to account setting 2020-05-02 00:45:48 +00:00
observers Add conversation message created live event 2020-04-07 19:30:23 +00:00
presenters rewrite grades presenter course score statistic to be cached 2020-04-23 19:37:50 +00:00
requests
schemas/lti Import and validate public JWK 2018-10-02 13:06:45 +00:00
selenium Show file rename dialogs after clicking Add Item 2020-05-01 21:10:44 +00:00
serializers rails 6: s/update_attributes/update/g 2020-01-09 20:56:35 +00:00
shared_examples spec: update submissions controllers for post policies 2020-03-11 14:39:35 +00:00
support use parallel_tests for more parallelization 2020-03-30 21:38:47 +00:00
views Integrate UploadForm into module item select_content_dialog 2020-04-25 16:12:28 +00:00
.eslintrc
.rspec_parallel use parallel_tests for more parallelization 2020-03-30 21:38:47 +00:00
ams_spec_helper.rb
broadcast_integration.rb
cassandra_spec_helper.rb spec: truncate cassandra tables before specs 2019-09-10 14:20:20 +00:00
coverage_tool.rb
feature_flag_helper.rb spec: get post_grades_to_sis tests to pass 2018-10-22 19:31:26 +00:00
file_upload_helper.rb spec: Make sure host is removed from quiz question data 2018-09-19 17:16:47 +00:00
force_failure_spec.rb Add force-failure flags for selenium and rspec 2020-04-22 18:42:53 +00:00
import_helper.rb
jspec.sh
lti2_course_spec_helper.rb
lti2_spec_helper.rb Distinguish course/account tool installs in ACTL 2019-11-05 18:28:45 +00:00
lti_1_3_spec_helper.rb Update external tools on tool config changes 2019-05-23 16:10:11 +00:00
lti_spec_helper.rb Prevent spec from making request to external LTI config endpoint 2019-04-12 20:07:42 +00:00
quiz_spec_helper.rb
rcov.opts
rspec_mock_extensions.rb
sharding_spec_helper.rb
simple_cov_result_merger.rb
spec.opts spec: watch new rspec builds for stability 2019-12-13 22:14:36 +00:00
spec_helper.rb remove unused selinimum gem 2020-04-23 17:25:57 +00:00