FEATURE: Add 'New users only' option to user_updated trigger (#26648)

This commit adds a new option to the `user_updated` trigger of the automation plugin to only trigger an automation for new users that join after the automation is enabled.

Internal topic: t/125829/9.
This commit is contained in:
Osama Sayegh
2024-04-16 21:13:11 +03:00
committed by GitHub
parent 57d29b6f3b
commit 4733369f71
7 changed files with 190 additions and 2 deletions

View File

@ -165,4 +165,21 @@ describe DiscourseAutomation::Automation do
end
end
end
describe "after_destroy" do
fab!(:automation) { Fabricate(:automation, enabled: false) }
fab!(:automation2) { Fabricate(:automation, enabled: false) }
it "deletes user custom fields that indicate new users" do
user = Fabricate(:user)
user.custom_fields[automation.new_user_custom_field_name] = "1"
user.custom_fields[automation2.new_user_custom_field_name] = "1"
user.save_custom_fields
automation.destroy!
user.reload
expect(user.custom_fields).to eq({ automation2.new_user_custom_field_name => "1" })
end
end
end