Module: AfterCommit::TestBypass
- Defined in:
- lib/after_commit/test_bypass.rb
Overview
The single transaction means that after_commit callback never happens in tests. Each of these method definitions overwrites the method in the after_commit plugin that stores the callback for after the commit. In each case here we simply call the callback rather than waiting for a commit that will never come.
Class Method Summary collapse
Instance Method Summary collapse
- #add_committed_record_on_create ⇒ Object
- #add_committed_record_on_destroy ⇒ Object
- #add_committed_record_on_update ⇒ Object
Class Method Details
.included(klass) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/after_commit/test_bypass.rb', line 8 def self.included(klass) klass.class_eval do [:add_committed_record_on_create, :add_committed_record_on_update, :add_committed_record_on_destroy].each do |method| remove_method(method) end end end |
Instance Method Details
#add_committed_record_on_create ⇒ Object
16 17 18 19 |
# File 'lib/after_commit/test_bypass.rb', line 16 def add_committed_record_on_create after_commit_callback after_commit_on_create_callback end |
#add_committed_record_on_destroy ⇒ Object
26 27 28 29 |
# File 'lib/after_commit/test_bypass.rb', line 26 def add_committed_record_on_destroy after_commit_callback after_commit_on_destroy_callback end |
#add_committed_record_on_update ⇒ Object
21 22 23 24 |
# File 'lib/after_commit/test_bypass.rb', line 21 def add_committed_record_on_update after_commit_callback after_commit_on_update_callback end |