DEV: adds topic_url/topic_title placeholders (#28754)
`topic_tags_changed` trigger now fills the {{topic_url}} and {{topic_title}} placeholders. `topic_url` is the relative URL.
This commit is contained in:
parent
dc1afeac89
commit
1a96269be0
|
@ -230,6 +230,10 @@ module DiscourseAutomation
|
|||
"topic" => topic,
|
||||
"removed_tags" => removed_tags,
|
||||
"added_tags" => added_tags,
|
||||
"placeholders" => {
|
||||
"topic_url" => topic.relative_url,
|
||||
"topic_title" => topic.title,
|
||||
},
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,4 +3,7 @@
|
|||
DiscourseAutomation::Triggerable.add(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED) do
|
||||
field :watching_categories, component: :categories
|
||||
field :watching_tags, component: :tags
|
||||
|
||||
placeholder :topic_url
|
||||
placeholder :topic_title
|
||||
end
|
||||
|
|
|
@ -32,6 +32,19 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
|
|||
automation.reload
|
||||
end
|
||||
|
||||
it "fills placeholders correctly" do
|
||||
topic_0 = Fabricate(:topic, user: user, tags: [], category: category)
|
||||
|
||||
list =
|
||||
capture_contexts do
|
||||
DiscourseTagging.tag_topic_by_names(topic_0, Guardian.new(user), [cool_tag.name])
|
||||
end
|
||||
|
||||
expect(list[0]["placeholders"]).to eq(
|
||||
{ "topic_title" => topic_0.title, "topic_url" => topic_0.relative_url },
|
||||
)
|
||||
end
|
||||
|
||||
it "should fire the trigger if the tag is added" do
|
||||
topic_0 = Fabricate(:topic, user: user, tags: [], category: category)
|
||||
|
||||
|
|
Loading…
Reference in New Issue