DEV: Allow DB.after_commit to be used outside of a transaction

In this case, it will execute the given block immediately
This commit is contained in:
David Taylor
2020-05-01 16:37:43 +01:00
parent 3877ef2cfa
commit 5901717531
2 changed files with 22 additions and 1 deletions

View File

@ -49,6 +49,19 @@ describe MiniSqlMultisiteConnection do
expect(outputString).to eq("123")
end
it "runs immediately if there is no transaction" do
outputString = "1"
DB.after_commit do
outputString += "2"
end
outputString += "3"
expect(outputString).to eq("123")
end
end
end