Disconnect action cable when user is deactivated
ref: https://app.fizzy.do/5986089/cards/2785
This commit is contained in:
@@ -24,10 +24,16 @@ class User < ApplicationRecord
|
||||
transaction do
|
||||
accesses.destroy_all
|
||||
update! active: false, identity: nil
|
||||
close_remote_connections
|
||||
end
|
||||
end
|
||||
|
||||
def setup?
|
||||
name != identity.email_address
|
||||
end
|
||||
|
||||
private
|
||||
def close_remote_connections
|
||||
ActionCable.server.remote_connections.where(current_user: self).disconnect(reconnect: false)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,7 +25,10 @@ class UserTest < ActiveSupport::TestCase
|
||||
test "deactivate" do
|
||||
assert_changes -> { users(:jz).active? }, from: true, to: false do
|
||||
assert_changes -> { users(:jz).accesses.count }, from: 1, to: 0 do
|
||||
users(:jz).deactivate
|
||||
users(:jz).tap do |user|
|
||||
user.stubs(:close_remote_connections).once
|
||||
user.deactivate
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user