FIX: thread safety for active automation tracking (#27044)

This commit is contained in:
Sam
2024-05-16 13:34:24 +10:00
committed by GitHub
parent 7442cf3f62
commit e90e6e8f86
2 changed files with 16 additions and 2 deletions

View File

@ -16,6 +16,20 @@ describe DiscourseAutomation::Triggerable do
fab!(:automation) { Fabricate(:automation, trigger: "foo") }
describe "active automation thread safety" do
after { DiscourseAutomation.set_active_automation(nil) }
it "ensurese thread safety when setting automation id" do
DiscourseAutomation.set_active_automation(10)
thread = Thread.new { DiscourseAutomation.get_active_automation }
thread.join
expect(thread.value).to eq(nil)
expect(DiscourseAutomation.get_active_automation).to eq(10)
end
end
describe "#setting" do
before { DiscourseAutomation::Triggerable.add("foo") { setting :bar, :baz } }