Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Make after_commit callbacks fire in tests for Rails 3+ with transactional_fixtures = true.
Ruby
Failed to load latest commit information.
gemfiles cleanup
lib v0.4.1
spec fix nested after_commit callbacks
.travis.yml Support for Rails 4.2
Gemfile kill appraisl
Gemfile.lock v0.4.1
MIT-LICENSE rename to mit
Rakefile kill appraisl
Readme.md thanks @be9
test_after_commit.gemspec rename to mit

Readme.md

Make after_commit callbacks fire in tests for Rails 3+ with transactional_fixtures = true.

Deprecation this is no longer needed on rails 5.0+ https://github.com/rails/rails/pull/18458

Install

gem install test_after_commit

# Gemfile (never include in :development !)
gem 'test_after_commit', :group => :test

Usage

Test that the methods get called or the side-effect of the methods, something like:

class Car < ActiveRecord::Base
  after_commit :foo, :on => :update

  def foo
    $foo = 1
  end
end

...

it "sets $foo on commit" do
  $foo.should == nil
  car.save!
  $foo.should == 1
end

TIPS

Author

Inspired by https://gist.github.com/1305285

Contributors

Michael Grosser
michael@grosser.it
License: MIT
Build Status

Something went wrong with that request. Please try again.