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

Test run_after_commit that is run after transaction

parent c02ba468
......@@ -4,15 +4,35 @@ require 'spec_helper'
RSpec.describe AfterCommitQueue do
describe '#run_after_commit' 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
......
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