mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 09:58:18 +08:00
FEATURE: Change tags sent in topic_tags_changed trigger in automation plugin (#28318)
* FEATURE: Change tags sent in topic_tags_changed trigger in discourse_automation Before, it was sending the old tags and the current tags in topic. Now, it sends the removed tags and the added tags in the topic. * DEV: update `missing_tags` to be `removed_tags` * DEV: add spacing for better readability
This commit is contained in:
@ -5,6 +5,8 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
|
||||
|
||||
fab!(:cool_tag) { Fabricate(:tag) }
|
||||
fab!(:bad_tag) { Fabricate(:tag) }
|
||||
fab!(:another_tag) { Fabricate(:tag) }
|
||||
|
||||
fab!(:category)
|
||||
|
||||
fab!(:user)
|
||||
@ -132,5 +134,41 @@ describe DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED do
|
||||
expect(list.length).to eq(1)
|
||||
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
|
||||
end
|
||||
|
||||
it "should send the correct removed tags in context" do
|
||||
topic_0 = Fabricate(:topic, user: user, tags: [cool_tag], category: category)
|
||||
|
||||
list =
|
||||
capture_contexts do
|
||||
DiscourseTagging.tag_topic_by_names(
|
||||
topic_0,
|
||||
Guardian.new(user),
|
||||
[bad_tag.name, another_tag.name],
|
||||
)
|
||||
end
|
||||
|
||||
expect(list.length).to eq(1)
|
||||
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
|
||||
expect(list[0]["added_tags"]).to eq([bad_tag.name, another_tag.name])
|
||||
expect(list[0]["removed_tags"]).to eq([cool_tag.name])
|
||||
end
|
||||
|
||||
it "should send the correct added tags in context" do
|
||||
topic_0 = Fabricate(:topic, user: user, tags: [cool_tag], category: category)
|
||||
|
||||
list =
|
||||
capture_contexts do
|
||||
DiscourseTagging.tag_topic_by_names(
|
||||
topic_0,
|
||||
Guardian.new(user),
|
||||
[cool_tag.name, another_tag.name],
|
||||
)
|
||||
end
|
||||
|
||||
expect(list.length).to eq(1)
|
||||
expect(list[0]["kind"]).to eq(DiscourseAutomation::Triggers::TOPIC_TAGS_CHANGED)
|
||||
expect(list[0]["added_tags"]).to eq([another_tag.name])
|
||||
expect(list[0]["removed_tags"]).to eq([])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user