Skip to content

Commit 3ca082b

Browse files
committed
add tests
1 parent 72a5713 commit 3ca082b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/stream-chat/moderation.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Moderation
1515
{
1616
user: 'stream:user',
1717
message: 'stream:chat:v1:message',
18-
userprofile: 'stream:v1:user_profile',
18+
userprofile: 'stream:v1:user_profile'
1919
}.freeze,
2020
T::Hash[Symbol, String]
2121
)
@@ -38,6 +38,9 @@ def initialize(client)
3838
# @option profile [String] :username Username to be checked
3939
# @option profile [String] :image Image URL to be checked
4040
# @return [StreamChat::StreamResponse]
41+
#
42+
# example:
43+
# client.moderation.check_user_profile('user-id', {username: 'bad_username', image: 'https://example.com/profile.jpg'})
4144
sig do
4245
params(
4346
user_id: String,

spec/moderation_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,24 @@ def loop_times(times)
159159
expect(response['duration']).not_to be_nil
160160
end
161161

162+
it 'check user profile' do
163+
response = @moderation.check_user_profile(
164+
@test_user_id,
165+
{ username: 'fuck_you_123' }
166+
)
167+
expect(response['duration']).not_to be_nil
168+
expect(response['status']).to eq('complete')
169+
expect(response['recommended_action']).to eq('remove')
170+
171+
response = @moderation.check_user_profile(
172+
@test_user_id,
173+
{ username: 'hi' }
174+
)
175+
expect(response['duration']).not_to be_nil
176+
expect(response['status']).to eq('complete')
177+
expect(response['recommended_action']).to eq('keep')
178+
end
179+
162180
it 'config test' do
163181
# Create moderation config
164182
moderation_config = {

0 commit comments

Comments
 (0)