test_after_commit 1.1.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Readme.md +1 -0
- data/lib/test_after_commit/database_statements.rb +16 -10
- data/lib/test_after_commit/version.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9ba199df5f7861c050858a4c97ef739fd8e2d5c8425955be89ac189cbbc3dded
|
4
|
+
data.tar.gz: fd5998ae5a1032733da2951a501ef9a049f4060c3818370bc89b47cc0ded7d56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7bcd2bfc6e37566ef925da38962d5951eb8fbc8e535e0392e132e7b947fa213c4267a80995e59c81c8978f82a63a5794cb1592bba28992488252aca33dba461
|
7
|
+
data.tar.gz: de0f8b1ebe5285939fceeb1240bf03dcee056c2a28871f9d7f4cb538014b726ebfad195696fe207ebc1789412a2ae5483845094b0cd033a14346b0bda563a456
|
data/Readme.md
CHANGED
@@ -71,6 +71,7 @@ Inspired by https://gist.github.com/1305285
|
|
71
71
|
- [Brian Palmer](https://github.com/codekitchen)
|
72
72
|
- [Oleg Dashevskii](https://github.com/be9)
|
73
73
|
- [Jonathan Spies](https://github.com/jspies)
|
74
|
+
- [Nick Sieger](https://github.com/nicksieger)
|
74
75
|
|
75
76
|
[Michael Grosser](http://grosser.it)<br/>
|
76
77
|
michael@grosser.it<br/>
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module TestAfterCommit::DatabaseStatements
|
2
2
|
def transaction(*)
|
3
3
|
@test_open_transactions ||= 0
|
4
|
+
skip_emulation = ActiveRecord::Base.connection.open_transactions.zero?
|
5
|
+
run_callbacks = false
|
6
|
+
result = nil
|
7
|
+
rolled_back = false
|
4
8
|
|
5
9
|
super do
|
6
10
|
begin
|
@@ -13,20 +17,19 @@ module TestAfterCommit::DatabaseStatements
|
|
13
17
|
rolled_back = true
|
14
18
|
raise
|
15
19
|
ensure
|
16
|
-
|
17
|
-
|
18
|
-
if
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@_current_transaction_records.clear
|
23
|
-
end
|
20
|
+
@test_open_transactions -= 1
|
21
|
+
if @test_open_transactions == 0 && !rolled_back && !skip_emulation
|
22
|
+
if TestAfterCommit.enabled
|
23
|
+
run_callbacks = true
|
24
|
+
elsif ActiveRecord::VERSION::MAJOR == 3
|
25
|
+
@_current_transaction_records.clear
|
24
26
|
end
|
25
|
-
ensure
|
26
|
-
result
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
|
+
ensure
|
31
|
+
test_commit_records if run_callbacks
|
32
|
+
result
|
30
33
|
end
|
31
34
|
|
32
35
|
def test_commit_records
|
@@ -40,6 +43,9 @@ module TestAfterCommit::DatabaseStatements
|
|
40
43
|
# This is because we're re-using the transaction on the stack, before
|
41
44
|
# it's been popped off and re-created by the AR code.
|
42
45
|
original = @transaction || @transaction_manager.current_transaction
|
46
|
+
|
47
|
+
return unless original.respond_to?(:records)
|
48
|
+
|
43
49
|
transaction = original.dup
|
44
50
|
transaction.instance_variable_set(:@records, transaction.records.dup) # deep clone of records array
|
45
51
|
original.records.clear # so that this clear doesn't clear out both copies
|
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: 1.
|
4
|
+
version: 1.2.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:
|
11
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: wwtd
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
132
|
version: '0'
|
127
133
|
requirements: []
|
128
134
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.7.6
|
130
136
|
signing_key:
|
131
137
|
specification_version: 4
|
132
138
|
summary: makes after_commit callbacks testable in Rails 3+ with transactional_fixtures
|