New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

test_after_commit

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

test_after_commit

  • 1.2.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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

Temporary disable after commit hooks

In your test_helper, you can specify the default

TestAfterCommit.enabled = true

Then use blocks in your tests to change the behavior:

TestAfterCommit.with_commits(true) do
  my_tests
end

TestAfterCommit.with_commits(false) do
  my_tests
end

TIPS

Author

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

Contributors

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

FAQs

Package last updated on 14 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc