mirror of
https://github.com/discourse/discourse.git
synced 2025-02-06 19:38:24 +00:00
0a1432e1cc
Prior to this fix we could exit early if tags was `[]` as `tags && (tags & post.topic.tags.map(&:name)).empty?` would have returned true. This commit ensures it's not the case anymore and adds a test for it. Co-Authored-By: Martin Brennan <mjrbrennan@gmail.com>
25 lines
778 B
Ruby
25 lines
778 B
Ruby
# frozen_string_literal: true
|
|
|
|
describe DiscourseAutomation::EventHandlers do
|
|
describe "#handle_stalled_topic" do
|
|
context "when tags are empty" do
|
|
fab!(:automation) do
|
|
Fabricate(:automation, trigger: DiscourseAutomation::Triggers::STALLED_TOPIC, enabled: true)
|
|
end
|
|
fab!(:user)
|
|
fab!(:post) { Fabricate(:post, user: user) }
|
|
|
|
before do
|
|
automation.upsert_field!("tags", "tags", { value: [] }, target: "trigger")
|
|
Fabricate(:user_global_notice, identifier: automation.id, user_id: user.id)
|
|
end
|
|
|
|
it "destroys notices" do
|
|
expect { DiscourseAutomation::EventHandlers.handle_stalled_topic(post) }.to change {
|
|
DiscourseAutomation::UserGlobalNotice.count
|
|
}.by(-1)
|
|
end
|
|
end
|
|
end
|
|
end
|