fix cross-shard merges that copy retired sms communication channels
test plan: * add an sms channel to a user * retire that channel * merge that user with a user in a different shard Change-Id: Ibd24978c7456505b813961044b635b99b6beec6b Reviewed-on: https://gerrit.instructure.com/15318 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
parent
6edaff4a7d
commit
261ba20b14
|
@ -35,7 +35,7 @@ class CommunicationChannel < ActiveRecord::Base
|
|||
before_save :consider_building_pseudonym
|
||||
validates_presence_of :path
|
||||
validate :uniqueness_of_path
|
||||
validate :not_otp_communication_channel, :if => lambda { |cc| cc.path_type == TYPE_SMS && cc.retired? }
|
||||
validate :not_otp_communication_channel, :if => lambda { |cc| cc.path_type == TYPE_SMS && cc.retired? && !cc.new_record? }
|
||||
|
||||
acts_as_list :scope => :user_id
|
||||
|
||||
|
|
|
@ -829,6 +829,22 @@ describe User do
|
|||
['o@instructure.com', 'retired']
|
||||
]
|
||||
end
|
||||
|
||||
it "should not fail copying retired sms channels" do
|
||||
@user1 = User.create!
|
||||
@shard1.activate do
|
||||
@user2 = User.create!
|
||||
end
|
||||
|
||||
@cc = @user2.communication_channels.sms.create!(:path => 'abc')
|
||||
@cc.retire!
|
||||
|
||||
@user2.move_to_user(@user1)
|
||||
@user1.communication_channels.reload.length.should == 1
|
||||
cc = @user1.communication_channels.first
|
||||
cc.path.should == 'abc'
|
||||
cc.workflow_state.should == 'retired'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue