Commit 7d81e0a7 authored by Thong Kuah's avatar Thong Kuah

Test run_after_commit that is run after transaction

parent c02ba468
......@@ -4,17 +4,37 @@ require 'spec_helper'
RSpec.describe AfterCommitQueue do
describe '#run_after_commit' do
it 'runs after transaction is committed' do
it 'runs after record is saved' do
called = false
test_proc = proc { called = true }
project = build(:project)
project.run_after_commit(&test_proc)
expect(called).to be false
# save! is run in its own transaction
project.save!
expect(called).to be true
end
it 'runs after transaction is committed' do
called = false
test_proc = proc { called = true }
project = build(:project)
Project.transaction do
project.run_after_commit(&test_proc)
project.save!
expect(called).to be false
end
expect(called).to be true
end
end
describe '#run_after_commit_or_now' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment