test_after_commit 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1608cb8ff6912879949fa15813e2c0ddf8ed3842
4
- data.tar.gz: 45d98ac0898d38149343f214660d6aff700ab199
3
+ metadata.gz: be5c7c35e9b83e1cf522ca5c7cfd3f046a56ca33
4
+ data.tar.gz: e2cb178b2b1584c88d607db6540bbe17e3834a71
5
5
  SHA512:
6
- metadata.gz: a86d361057e8211f964d23e68e93d369213b6dc1939dad62ffde1a246ea1e99c3c125b7a42eca1a4ccbc176bca19048db80dba6e2295b2c2c979b71fba7adfa0
7
- data.tar.gz: 938b6410eb30165805607c930b150884080337b344bd106e488b59cea85dc1ea252321adaa43228ffa8efbc6b814910af223a9d9be9805c67197730e34dcd7ea
6
+ metadata.gz: f8a232c5bbb1bfbcefa6c4772cb4d01d7a95f55bdb8e3732bfcef90ccf2f512ec55e76d87e36e6eda0dda6b9dac644abef0088562adc401c673cf198b96cb871
7
+ data.tar.gz: 2047d7d6342337a640a222e45d79616c9c14af4f8184e01db39fb1cbfc8828ec7e9b210bec851afacc623df026cb5e82f5b37c504acc4fc57c334a82d2fd99b2
data/Readme.md CHANGED
@@ -32,6 +32,26 @@ it "sets $foo on commit" do
32
32
  end
33
33
  ```
34
34
 
35
+ ### Temporary disable after commit hooks
36
+
37
+ In your test_helper, you can specify the default
38
+
39
+ ```
40
+ TestAfterCommit.enabled = true
41
+ ```
42
+
43
+ Then use blocks in your tests to change the behavior:
44
+
45
+ ```
46
+ TestAfterCommit.with_commits(true) do
47
+ my_tests
48
+ end
49
+
50
+ TestAfterCommit.with_commits(false) do
51
+ my_tests
52
+ end
53
+ ```
54
+
35
55
  TIPS
36
56
  ====
37
57
  - hooks do not re-raise errors (with or without this gem) use [after_commit_exception_notification](https://github.com/grosser/after_commit_exception_notification)
@@ -49,6 +69,7 @@ Inspired by https://gist.github.com/1305285
49
69
  - [lsylvester](https://github.com/lsylvester)
50
70
  - [Tony Novak](https://github.com/afn)
51
71
  - [Brian Palmer](https://github.com/codekitchen)
72
+ - [Oleg Dashevskii](https://github.com/be9)
52
73
 
53
74
  [Michael Grosser](http://grosser.it)<br/>
54
75
  michael@grosser.it<br/>
@@ -1,6 +1,18 @@
1
1
  require 'test_after_commit/version'
2
2
 
3
3
  module TestAfterCommit
4
+ @enabled = true
5
+ class << self
6
+ attr_accessor :enabled
7
+
8
+ def with_commits(value = true)
9
+ old = enabled
10
+ self.enabled = value
11
+ yield
12
+ ensure
13
+ self.enabled = old
14
+ end
15
+ end
4
16
  end
5
17
 
6
18
  ActiveRecord::ConnectionAdapters::DatabaseStatements.class_eval do
@@ -19,7 +31,7 @@ ActiveRecord::ConnectionAdapters::DatabaseStatements.class_eval do
19
31
  ensure
20
32
  begin
21
33
  @test_open_transactions -= 1
22
- if @test_open_transactions == 0 && !rolled_back
34
+ if TestAfterCommit.enabled && @test_open_transactions == 0 && !rolled_back
23
35
  test_commit_records
24
36
  end
25
37
  ensure
@@ -1,3 +1,3 @@
1
1
  module TestAfterCommit
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_after_commit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-11 00:00:00.000000000 Z
11
+ date: 2015-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  requirements: []
126
126
  rubyforge_project:
127
- rubygems_version: 2.2.2
127
+ rubygems_version: 2.4.5.1
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: makes after_commit callbacks testable in Rails 3+ with transactional_fixtures