fix sending immediate notifications for delayed policies
test plan: * create a user in a course with a confirmed email * as that user, view the notificatio settings and override a testable notification type (e.g. Announcements) to send later (daily/weekly) * override another type to send immediately * test the notification (e.g. add an announcement to the course) * should not send the notification right away closes #CORE-2815 Change-Id: I8930d1ff4142a5128224023bcdfdcf9c2458bcc0 Reviewed-on: https://gerrit.instructure.com/190165 Reviewed-by: Cody Cutrer <cody@instructure.com> Reviewed-by: Rob Orton <rob@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com> QA-Review: Rob Orton <rob@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> Product-Review: Rob Orton <rob@instructure.com> Tested-by: Jenkins
This commit is contained in:
parent
0652df5e37
commit
2be249c487
|
@ -281,7 +281,7 @@ class NotificationMessageCreator
|
|||
return [] unless user.registered?
|
||||
|
||||
active_channel_scope = user.communication_channels.select { |cc| cc.active? && cc.notification_policies.find { |np| np.notification_id == @notification.id } }
|
||||
immediate_channel_scope = active_channel_scope.select { |cc| cc.notification_policies.find { |np| np.frequency == 'immediately' } }
|
||||
immediate_channel_scope = active_channel_scope.select { |cc| cc.notification_policies.find { |np| np.notification_id == @notification.id && np.frequency == 'immediately' } }
|
||||
|
||||
user_has_a_policy = active_channel_scope.find { |cc| cc.path_type != 'push' }
|
||||
if !user_has_a_policy && @notification.default_frequency(user) == 'immediately'
|
||||
|
|
|
@ -237,6 +237,18 @@ describe NotificationMessageCreator do
|
|||
expect { NotificationMessageCreator.new(@notification, @assignment, :to_list => @user).create_message }.to change(DelayedMessage, :count).by 3
|
||||
end
|
||||
|
||||
it "should make a delayed message for a notification with a set delayed frequency (even if another policy is set to immediate)" do
|
||||
notification_set
|
||||
@notification_policy.update_attribute(:frequency, 'daily')
|
||||
|
||||
other_notification = Notification.create!(:subject => "yo", :name => "Test Not 2")
|
||||
other_np = NotificationPolicy.create!(:notification => other_notification, :communication_channel => @communication_channel)
|
||||
|
||||
NotificationMessageCreator.new(@notification, @assignment, :to_list => @user).create_message
|
||||
expect(Message.where(:communication_channel_id => @communication_channel).exists?).to eq false # no immediate message
|
||||
expect(DelayedMessage.where(:communication_channel_id => @communication_channel).exists?).to eq true
|
||||
end
|
||||
|
||||
it "should make a delayed message for the default channel based on the notification's default frequency when there is no policy on any channel for the notification" do
|
||||
notification_set # we get one channel here
|
||||
communication_channel_model(path: 'yes@example.com').confirm! # this gives us a total of two channels
|
||||
|
|
Loading…
Reference in New Issue