|
316 | 316 | expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id)
|
317 | 317 | end
|
318 | 318 |
|
319 |
| - describe "With `create_post_for_category_and_tag_changes` enabled" do |
320 |
| - before(:each) { SiteSetting.create_post_for_category_and_tag_changes = true } |
321 |
| - |
322 |
| - let(:admin) { Fabricate(:admin) } |
323 |
| - let(:other_topic) { Fabricate(:topic) } |
324 |
| - let(:other_topic_post) { Fabricate(:post, topic: topic) } |
325 |
| - |
326 |
| - it "should trigger follow rules for specific categories when topic category changes" do |
327 |
| - DiscourseChatIntegration::Rule.create!( |
328 |
| - channel: chan1, |
329 |
| - filter: "follow", |
330 |
| - category_id: category.id, |
331 |
| - ) |
332 |
| - |
333 |
| - PostRevisor.new(other_topic_post).revise!(admin, category_id: category.id) |
334 |
| - |
335 |
| - manager.trigger_notifications(topic.ordered_posts.last.id) |
336 |
| - |
337 |
| - expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id) |
338 |
| - end |
339 |
| - |
340 |
| - it "shouldn't trigger follow rules with wildcard category match" do |
341 |
| - DiscourseChatIntegration::Rule.create!(channel: chan1, filter: "follow", category_id: nil) |
342 |
| - |
343 |
| - PostRevisor.new(other_topic_post).revise!(admin, category_id: category.id) |
344 |
| - |
345 |
| - manager.trigger_notifications(topic.ordered_posts.last.id) |
346 |
| - |
347 |
| - expect(provider.sent_to_channel_ids).to contain_exactly |
348 |
| - end |
349 |
| - end |
350 |
| - |
351 | 319 | describe "with tags enabled" do
|
352 | 320 | let(:tag) { Fabricate(:tag, name: "gsoc") }
|
353 | 321 | let(:tagged_topic) { Fabricate(:topic, category_id: category.id, tags: [tag]) }
|
|
377 | 345 |
|
378 | 346 | expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id)
|
379 | 347 | end
|
380 |
| - |
381 |
| - describe "with create_small_action_post_for_tag_changes enabled" do |
382 |
| - fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) } |
383 |
| - fab!(:additional_tag) { Fabricate(:tag) } |
384 |
| - |
385 |
| - before { SiteSetting.create_post_for_category_and_tag_changes = true } |
386 |
| - |
387 |
| - def set_new_tags_and_return_small_action_post(tags) |
388 |
| - PostRevisor.new(tagged_first_post).revise!(admin, tags: tags) |
389 |
| - |
390 |
| - tagged_topic.ordered_posts.last |
391 |
| - end |
392 |
| - |
393 |
| - it "should notify when rule is set up for tag additions for a category with no tag filter" do |
394 |
| - post = set_new_tags_and_return_small_action_post([tag.name, additional_tag.name]) |
395 |
| - |
396 |
| - DiscourseChatIntegration::Rule.create!( |
397 |
| - channel: chan1, |
398 |
| - filter: "tag_added", |
399 |
| - category_id: category.id, |
400 |
| - ) |
401 |
| - |
402 |
| - manager.trigger_notifications(post.id) |
403 |
| - expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id) |
404 |
| - end |
405 |
| - |
406 |
| - it "notifies when topic has a tag added that matches the rule" do |
407 |
| - post = set_new_tags_and_return_small_action_post([tag.name, additional_tag.name]) |
408 |
| - |
409 |
| - DiscourseChatIntegration::Rule.create!( |
410 |
| - channel: chan1, |
411 |
| - filter: "tag_added", |
412 |
| - category_id: category.id, |
413 |
| - tags: [additional_tag.name], |
414 |
| - ) |
415 |
| - |
416 |
| - manager.trigger_notifications(post.id) |
417 |
| - expect(provider.sent_to_channel_ids).to contain_exactly(chan1.id) |
418 |
| - end |
419 |
| - |
420 |
| - it "doesn't notify when a new regular post is created" do |
421 |
| - DiscourseChatIntegration::Rule.create!( |
422 |
| - channel: chan1, |
423 |
| - filter: "tag_added", |
424 |
| - category_id: nil, |
425 |
| - tags: [tag.name], |
426 |
| - ) |
427 |
| - |
428 |
| - post = Fabricate(:post, topic: tagged_topic) |
429 |
| - manager.trigger_notifications(post.id) |
430 |
| - expect(provider.sent_to_channel_ids).to contain_exactly |
431 |
| - end |
432 |
| - |
433 |
| - it "doesn't notify when topic has an unchanged tag present in the rule, even if a new tag is added" do |
434 |
| - post = set_new_tags_and_return_small_action_post([tag.name, additional_tag.name]) |
435 |
| - |
436 |
| - DiscourseChatIntegration::Rule.create!( |
437 |
| - channel: chan1, |
438 |
| - filter: "tag_added", |
439 |
| - category_id: category.id, |
440 |
| - tags: [tag.name], |
441 |
| - ) |
442 |
| - |
443 |
| - manager.trigger_notifications(post.id) |
444 |
| - expect(provider.sent_to_channel_ids).to contain_exactly |
445 |
| - end |
446 |
| - |
447 |
| - it "doesn't notify for small action 'tags_changed' posts unless a matching rule exists" do |
448 |
| - post = set_new_tags_and_return_small_action_post([additional_tag.name]) |
449 |
| - |
450 |
| - DiscourseChatIntegration::Rule.create!(channel: chan1, filter: "watch", category_id: nil) # Wildcard watch |
451 |
| - |
452 |
| - manager.trigger_notifications(post.id) |
453 |
| - expect(provider.sent_to_channel_ids).to contain_exactly |
454 |
| - end |
455 |
| - end |
456 | 348 | end
|
457 | 349 | end
|
458 | 350 | end
|
0 commit comments