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>