Skip to content

Commit 984c8e2

Browse files
feat: added test for partially updating a channel member
1 parent 0c95342 commit 984c8e2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/stream-chat/channel.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def unarchive(user_id)
222222
end
223223

224224
# Updates a member partially in the channel.
225-
sig { params(user_id: String, set: T.nilable(StringKeyHash), unset: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
225+
sig { params(user_id: String, set: T.nilable(StringKeyHash), unset: T.nilable(T::Array[String])).returns(StreamChat::StreamResponse) }
226226
def update_member_partial(user_id, set: nil, unset: nil)
227227
raise StreamChannelException, 'user ID must not be empty' if user_id.empty?
228228
raise StreamChannelException, 'set or unset is required' if set.nil? && unset.nil?

spec/channel_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,4 +338,17 @@ def loop_times(times)
338338
expect(response['channels'].length).to eq 1
339339
expect(response['channels'][0]['channel']['cid']).to eq @channel.cid
340340
end
341+
342+
it 'can update channel member partially' do
343+
@channel.add_members([@random_users[0][:id]])
344+
345+
# Test setting a field
346+
response = @channel.update_member_partial(@random_users[0][:id], set: { 'hat' => 'blue' })
347+
expect(response['channel_member']['hat']).to eq 'blue'
348+
349+
# Test setting and unsetting fields
350+
response = @channel.update_member_partial(@random_users[0][:id], set: { 'color' => 'red' }, unset: ['hat'])
351+
expect(response['channel_member']['color']).to eq 'red'
352+
expect(response['channel_member']).not_to have_key('hat')
353+
end
341354
end

0 commit comments

Comments
 (0)