drop notification_policies.broadcast
it's never used NotificationPolicy#preference also becomes obsolete, because NOT NULL and FK ensure that #communication_channel can never be nil; it's also never used Change-Id: I0669d3b89964ee6f6d4c6a62e348e276bb7ef315 Reviewed-on: https://gerrit.instructure.com/39446 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
381a8830fd
commit
6706a69c81
|
@ -25,7 +25,6 @@ class NotificationPolicy < ActiveRecord::Base
|
|||
attr_accessible :notification, :communication_channel, :frequency, :notification_id, :communication_channel_id
|
||||
|
||||
validates_presence_of :communication_channel_id, :frequency
|
||||
validates_inclusion_of :broadcast, in: [true, false]
|
||||
validates_inclusion_of :frequency, in: [Notification::FREQ_IMMEDIATELY,
|
||||
Notification::FREQ_DAILY,
|
||||
Notification::FREQ_WEEKLY,
|
||||
|
@ -52,11 +51,6 @@ class NotificationPolicy < ActiveRecord::Base
|
|||
|
||||
scope :in_state, lambda { |state| where(:workflow_state => state.to_s) }
|
||||
|
||||
def communication_preference
|
||||
return nil unless broadcast
|
||||
communication_channel || user.communication_channel
|
||||
end
|
||||
|
||||
def self.spam_blocked_by(user)
|
||||
NotificationPolicy.where(:communication_channel_id => user.communication_channels.pluck(:id)).delete_all
|
||||
cc = user.communication_channel
|
||||
|
|
|
@ -37,7 +37,7 @@ class ActiveRecord::Base
|
|||
'enrollments' => %w(invitation_email can_participate_before_start_at limit_priveleges_to_course_sections),
|
||||
'failed_jobs' => %w(original_id),
|
||||
'groups' => %w(sis_name type groupable_id groupable_type),
|
||||
'notification_policies' => %w(user_id),
|
||||
'notification_policies' => %w(user_id broadcast),
|
||||
'page_views' => %w(contributed),
|
||||
'pseudonyms' => %w(sis_update_data deleted_unique_id sis_source_id crypted_webdav_access_code type),
|
||||
'role_overrides' => %w(context_code),
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class DropBroadcastFromNotificationPolicies < ActiveRecord::Migration
|
||||
tag :postdeploy
|
||||
|
||||
def up
|
||||
remove_column :notification_policies, :broadcast
|
||||
end
|
||||
|
||||
def down
|
||||
add_column :notification_policies, :broadcast, :boolean, null: false, default: true
|
||||
end
|
||||
end
|
|
@ -24,16 +24,6 @@ describe NotificationPolicy do
|
|||
notification_policy_model
|
||||
end
|
||||
|
||||
it "should default broadcast to true" do
|
||||
notification_policy_model
|
||||
@notification_policy.broadcast.should be_true
|
||||
end
|
||||
|
||||
it "should not have a communication_preference if broadcast is set to false." do
|
||||
notification_policy_model(:broadcast => false)
|
||||
@notification_policy.communication_preference.should be_nil
|
||||
end
|
||||
|
||||
context "channels" do
|
||||
before(:once) do
|
||||
@course = factory_with_protected_attributes(Course, :name => "test course", :workflow_state => "available")
|
||||
|
@ -330,27 +320,3 @@ describe NotificationPolicy do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe NotificationPolicy, "communication_preference" do
|
||||
|
||||
before(:each) do
|
||||
@cc1 = mock('CommunicationChannel')
|
||||
@cc2 = mock('CommunicationChannel')
|
||||
@user = User.create!
|
||||
@user.stubs(:communication_channel).returns(@cc1)
|
||||
notification_policy_model
|
||||
@notification_policy.stubs(:user).returns(@user)
|
||||
end
|
||||
|
||||
it "should use the channel defined, if one is given" do
|
||||
@notification_policy.stubs(:communication_channel).returns(@cc2)
|
||||
@notification_policy.communication_preference.should == @cc2
|
||||
end
|
||||
|
||||
it "should use the users default communication channel if one isn't given" do
|
||||
@notification_policy.stubs(:communication_channel).returns(nil)
|
||||
@notification_policy.communication_preference.should == @cc1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue