mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
FEATURE: add trigger_with_pms
option to topic tags changed
automation trigger (#29122)
This commit is contained in:
@ -19,6 +19,7 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
|
||||
SiteSetting.tagging_enabled = true
|
||||
SiteSetting.create_tag_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
||||
SiteSetting.tag_topic_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
||||
SiteSetting.pm_tags_allowed_for_groups = Group::AUTO_GROUPS[:everyone]
|
||||
end
|
||||
|
||||
context "when watching a cool tag" do
|
||||
@ -185,5 +186,38 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
|
||||
expect(list[0]["added_tags"]).to eq([another_tag.name])
|
||||
expect(list[0]["removed_tags"]).to eq([])
|
||||
end
|
||||
|
||||
it "should not fire the trigger on PMs by default" do
|
||||
pm = Fabricate(:private_message_topic)
|
||||
list =
|
||||
capture_contexts do
|
||||
DiscourseTagging.tag_topic_by_names(
|
||||
pm,
|
||||
Guardian.new(user),
|
||||
[cool_tag.name, another_tag.name],
|
||||
)
|
||||
end
|
||||
expect(list.length).to eq(0)
|
||||
end
|
||||
|
||||
it "should fire the trigger on PMs if trigger_with_pms is set" do
|
||||
automation.upsert_field!(
|
||||
"trigger_with_pms",
|
||||
"boolean",
|
||||
{ "value" => true },
|
||||
target: "trigger",
|
||||
)
|
||||
|
||||
pm = Fabricate(:private_message_topic)
|
||||
list =
|
||||
capture_contexts do
|
||||
DiscourseTagging.tag_topic_by_names(
|
||||
pm,
|
||||
Guardian.new(user),
|
||||
[cool_tag.name, another_tag.name],
|
||||
)
|
||||
end
|
||||
expect(list.length).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user