don't error on the comm prefs page; refs #6914
When a user's immediate messages start getting throttled (like when they've received 50 in a day), we create a NotificationPolicy for that user with no Notification. That's not an ideal design, but rather than fix that now, we're just going to make sure those policies don't cause errors test plan: * See specs. Change-Id: Ib262b256a9d4fe5fe7fd882d6848883e7a40cb59 Reviewed-on: https://gerrit.instructure.com/8096 Reviewed-by: Cody Cutrer <cody@instructure.com> Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
parent
52d33b968b
commit
5896d1fd78
|
@ -110,7 +110,9 @@ class ProfileController < ApplicationController
|
|||
@active_tab = "communication-preferences"
|
||||
|
||||
# build placeholder notification policies for categories the user does not have policies for already
|
||||
user_categories = @user.notification_policies.map {|np| np.notification.category }
|
||||
# Note that currently a NotificationPolicy might not have a Notification attached to it.
|
||||
# See the relevant spec in profile_controller_spec.rb for more details.
|
||||
user_categories = @user.notification_policies.map {|np| np.notification.try(:category) }
|
||||
@notification_categories.each do |category|
|
||||
# category is actually a Notification
|
||||
next if user_categories.include?(category.category)
|
||||
|
|
|
@ -48,4 +48,20 @@ describe ProfileController do
|
|||
@cc.reload.position.should == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET 'communication'" do
|
||||
it "should not fail when a user has a notification policy with no notification" do
|
||||
# A user might have a NotificationPolicy with no Notification if the policy was created
|
||||
# as part of throttling a user's "immediate" messages. Eventually we should fix how that
|
||||
# works, but for now we just make sure that that state does not cause an error for the
|
||||
# user when they go to their notification preferences.
|
||||
user_model
|
||||
user_session(@user)
|
||||
cc = @user.communication_channels.create!(:path => 'user@example.com', :path_type => 'email') { |cc| cc.workflow_state = 'active' }
|
||||
@user.notification_policies.create!(:notification => nil, :communication_channel => cc, :frequency => 'daily')
|
||||
|
||||
get 'communication'
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue