Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/stream-chat/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,7 @@ def revoke_user_token(user_id, before)
def revoke_users_token(user_ids, before)
before = StreamChat.normalize_timestamp(before)

updates = []
user_ids.map do |user_id|
updates = user_ids.map do |user_id|
{
'id' => user_id,
'set' => {
Expand Down
35 changes: 35 additions & 0 deletions spec/revoke_tokens_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

require 'stream-chat'

describe StreamChat::Client do
let(:client) { described_class.new('test-key', 'test-secret') }
let(:timestamp) { '2026-11-10T00:00:00+00:00' }
let(:response) { StreamChat::StreamResponse.new({}, Faraday::Response.new(status: 200, response_headers: {})) }

describe '#revoke_users_token' do
it 'sends a partial update for each requested user and normalizes the timestamp' do
updates = %w[alice bob].map do |id|
{ 'id' => id, 'set' => { 'revoke_tokens_issued_before' => timestamp } }
end
expect(client).to receive(:patch).with('users', data: { users: updates }).and_return(response)

expect(client.revoke_users_token(%w[alice bob], DateTime.parse(timestamp))).to equal(response)
end

it 'sends an empty update list when no users are requested' do
expect(client).to receive(:patch).with('users', data: { users: [] }).and_return(response)

expect(client.revoke_users_token([], timestamp)).to equal(response)
end
end

describe '#revoke_user_token' do
it 'sends the requested user and preserves a string timestamp' do
updates = [{ 'id' => 'alice', 'set' => { 'revoke_tokens_issued_before' => timestamp } }]
expect(client).to receive(:patch).with('users', data: { users: updates }).and_return(response)

expect(client.revoke_user_token('alice', timestamp)).to equal(response)
end
end
end