|
217 | 217 | resp = @client.search({ members: { '$in' => ['legolas'] } }, text) |
218 | 218 | expect(resp['results'].length).to eq(1) |
219 | 219 | end |
| 220 | + |
| 221 | + it 'list available blocklists' do |
| 222 | + resp = @client.list_blocklists |
| 223 | + expect(resp['blocklists'].length).to eq 1 |
| 224 | + end |
| 225 | + |
| 226 | + it 'get blocklist profanity_en_2020_v1' do |
| 227 | + resp = @client.get_blocklist('profanity_en_2020_v1') |
| 228 | + expect(resp['blocklist']['name']).to eq 'profanity_en_2020_v1' |
| 229 | + end |
| 230 | + |
| 231 | + it 'create a new blocklist' do |
| 232 | + @client.create_blocklist('no-cakes', %w[fudge cream sugar]) |
| 233 | + end |
| 234 | + |
| 235 | + it 'list available blocklists' do |
| 236 | + resp = @client.list_blocklists |
| 237 | + expect(resp['blocklists'].length).to eq 2 |
| 238 | + end |
| 239 | + |
| 240 | + it 'get blocklist info' do |
| 241 | + resp = @client.get_blocklist('no-cakes') |
| 242 | + expect(resp['blocklist']['name']).to eq 'no-cakes' |
| 243 | + expect(resp['blocklist']['words']).to eq %w[fudge cream sugar] |
| 244 | + end |
| 245 | + |
| 246 | + it 'update a default blocklist should fail' do |
| 247 | + expect do |
| 248 | + @client.update_blocklist('profanity_en_2020_v1', %w[fudge cream sugar vanilla]) |
| 249 | + end.to raise_error(/cannot update the builtin block list/) |
| 250 | + end |
| 251 | + |
| 252 | + it 'update blocklist' do |
| 253 | + @client.update_blocklist('no-cakes', %w[fudge cream sugar vanilla]) |
| 254 | + end |
| 255 | + |
| 256 | + it 'get blocklist info again' do |
| 257 | + resp = @client.get_blocklist('no-cakes') |
| 258 | + expect(resp['blocklist']['name']).to eq 'no-cakes' |
| 259 | + expect(resp['blocklist']['words']).to eq %w[fudge cream sugar vanilla] |
| 260 | + end |
| 261 | + |
| 262 | + it 'use the blocklist for a channel type' do |
| 263 | + @client.update_channel_type('messaging', blocklist: 'no-cakes', blocklist_behavior: 'block') |
| 264 | + end |
| 265 | + |
| 266 | + it 'should block messages that match the blocklist' do |
| 267 | + channel = @client.channel('messaging', channel_id: SecureRandom.uuid, data: { 'test' => true, 'language' => 'ruby' }) |
| 268 | + channel.create(@random_user[:id]) |
| 269 | + resp = channel.send_message({ text: 'put some sugar and fudge on that!' }, @random_user[:id]) |
| 270 | + expect(resp['message']['text']).to eq 'Automod blocked your message' |
| 271 | + expect(resp['message']['type']).to eq 'error' |
| 272 | + end |
| 273 | + |
| 274 | + it 'update blocklist again' do |
| 275 | + @client.update_blocklist('no-cakes', %w[fudge cream sugar vanilla jam]) |
| 276 | + end |
| 277 | + |
| 278 | + it 'should block messages that match the blocklist' do |
| 279 | + channel = @client.channel('messaging', channel_id: SecureRandom.uuid, data: { 'test' => true, 'language' => 'ruby' }) |
| 280 | + channel.create(@random_user[:id]) |
| 281 | + resp = channel.send_message({ text: 'you should add more jam there ;)' }, @random_user[:id]) |
| 282 | + expect(resp['message']['text']).to eq 'Automod blocked your message' |
| 283 | + expect(resp['message']['type']).to eq 'error' |
| 284 | + end |
| 285 | + |
| 286 | + it 'delete a blocklist' do |
| 287 | + @client.delete_blocklist('no-cakes') |
| 288 | + end |
| 289 | + |
| 290 | + it 'should not block messages anymore' do |
| 291 | + channel = @client.channel('messaging', channel_id: SecureRandom.uuid, data: { 'test' => true, 'language' => 'ruby' }) |
| 292 | + channel.create(@random_user[:id]) |
| 293 | + resp = channel.send_message({ text: 'put some sugar and fudge on that!' }, @random_user[:id]) |
| 294 | + expect(resp['message']['text']).to eq 'put some sugar and fudge on that!' |
| 295 | + end |
| 296 | + |
| 297 | + it 'list available blocklists' do |
| 298 | + resp = @client.list_blocklists |
| 299 | + expect(resp['blocklists'].length).to eq 1 |
| 300 | + end |
| 301 | + |
| 302 | + it 'delete a default blocklist should fail' do |
| 303 | + expect do |
| 304 | + @client.delete_blocklist('profanity_en_2020_v1') |
| 305 | + end.to raise_error( |
| 306 | + /cannot delete the builtin block list/ |
| 307 | + ) |
| 308 | + end |
220 | 309 | end |
0 commit comments