Skip to content

Instantly share code, notes, and snippets.

@gnufied
Created May 9, 2012 11:28
Show Gist options
  • Save gnufied/2643875 to your computer and use it in GitHub Desktop.
Save gnufied/2643875 to your computer and use it in GitHub Desktop.
class SaveFromAfterCommitBlockTest < ActiveRecord::TestCase
class TopicWithSaveInCallback < ActiveRecord::Base
self.table_name = :topics
after_commit :cache_topic, :on => :create
def cache_topic
puts "******************* calling this stuff again #{cached.inspect}"
unless cached
self.cached = true
self.save
else
self.cached = false
end
end
def cached=(value)
@cached = value
end
def cached
puts "returning #{@cached.inspect}"
@cached
end
end
def test_after_commit_in_save
t = TopicWithSaveInCallback.new()
t.save
puts "I am here"
end
end
@gnufied
Copy link
Author

gnufied commented May 9, 2012


Using mysql with Identity Map off
Run options: 

# Running tests:

returning nil
Value is nil
.returning nil
******************* calling this stuff again nil
..............

Finished tests in 0.373179s, 40.1952 tests/s, 61.6326 assertions/s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment