mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-11-04 03:14:06 +09:00
Close live connections on the transaction that changed the password
An after_commit condition reads the record's last save, so another save of the user in the same transaction skipped the disconnect even though the sessions were gone. The callback that deletes them now registers the disconnect on the transaction itself, which also leaves a rolled back change alone. A password changed along with the avatar is covered too: the attachment's touch doesn't hide the change.
This commit is contained in:
1 parent
b01bb7a0a7
commit
e158388f3d
3 files changed
+40
-5
No files matched your search
@@ -55,6 +55,19 @@ class Users::ProfilesControllerTest < ActionDispatch::IntegrationTest
|
||||
copy.assert_redirected_to new_session_url
|
||||
end
|
||||
|
||||
test "changing the password along with the avatar still signs this browser back in and closes live connections" do
|
||||
remote_connections = mock
|
||||
remote_connections.expects(:disconnect).with(reconnect: true)
|
||||
ActionCable.server.stubs(:remote_connections).returns(mock.tap { |m| m.expects(:where).with(current_user: users(:david)).returns(remote_connections) })
|
||||
|
||||
put user_profile_url, params: { user: { password: "a new secret123456", avatar: fixture_file_upload("moon.jpg", "image/jpeg") } }
|
||||
assert_redirected_to user_profile_url
|
||||
assert users(:david).reload.avatar.attached?
|
||||
|
||||
get user_profile_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "changing the password closes the account's live connections" do
|
||||
remote_connections = mock
|
||||
remote_connections.expects(:disconnect).with(reconnect: true)
|
||||
|
||||
Reference in new issue
Block a user