sequel_test_after_commit 0.0.3 → 0.0.4

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: b52b3e69a382c92ab94f784c4e0dfe705ead2b7e
4
- data.tar.gz: 00300d77b2e6e9935c69ae828565fc6b99438819
3
+ metadata.gz: 2741b2083df5a6cac22b15c28527e553507b99dd
4
+ data.tar.gz: 91019c6b88abe93e4388f1993bbad9cbddb2a99f
5
5
  SHA512:
6
- metadata.gz: 7b4cfc7426fd3efe263f207432627ae72cb386e770b1616adfb16407b867f4b9af8a473356269c75cf4611741c7bbd60355d4f483111fbc660c8e1a0380ecabf
7
- data.tar.gz: 117d66a0cc1008d6c9adee7bcb5eedf47c3d7a0cf1d5ffb10d5ee4889fc3132d6b4474bf833af15a3dbeea72f6eb3e734760aede273a59a144c8404502d7542b
6
+ metadata.gz: 07419e2a57fb6a371a59ec470c0b99f6e7c5e90ba16073d9e6e12342a67ade2ae35f685a976ff4f1d19b3f597fc1600c54933c1e715fc9edd5b668299ed412e2
7
+ data.tar.gz: 96eb18d1589b988c5c789ca86004fa8340f6c9503977aac6e9c11617805839d984d2a0a02b7a6cf340f6a4e826d2a46613aaf131ab9d75e539572e95bb456d5d
@@ -0,0 +1,11 @@
1
+ #### 0.0.4 (2014-08-12)
2
+
3
+ * When declaring an after_commit callback within another after_commit callback, it is now processed immediately rather than being added to the queue. This may not be expected behavior for some cases, but is consistent with the notion of treating the period immediately after a subtransaction ends as being outside of any transaction for testing purposes.
4
+
5
+ #### 0.0.3 (2014-06-28)
6
+
7
+ * Fix bug where transactions wouldn't be cleared if an error was raised while processing an after_commit hook.
8
+
9
+ #### 0.0.2 (2014-06-25)
10
+
11
+ * Initial release. Very simple, just runs after_commit hooks that were declared in a subtransaction when that subtransaction ends.
@@ -4,16 +4,22 @@ module Sequel
4
4
  level = savepoint_level(conn)
5
5
 
6
6
  if h = _trans(conn)
7
- if after_commit = h[:after_commit]
8
- if hooks = after_commit.delete(level)
9
- hooks.each(&:call) if committed
7
+ begin
8
+ h[:in_after_commit] = true
9
+
10
+ if after_commit = h[:after_commit]
11
+ if hooks = after_commit.delete(level)
12
+ hooks.each(&:call) if committed
13
+ end
10
14
  end
11
- end
12
15
 
13
- if after_rollback = h[:after_rollback]
14
- if hooks = after_rollback.delete(level)
15
- hooks.each(&:call) unless committed
16
+ if after_rollback = h[:after_rollback]
17
+ if hooks = after_rollback.delete(level)
18
+ hooks.each(&:call) unless committed
19
+ end
16
20
  end
21
+ ensure
22
+ h.delete(:in_after_commit)
17
23
  end
18
24
  end
19
25
  ensure
@@ -23,7 +29,7 @@ module Sequel
23
29
  def after_commit(opts=OPTS, &block)
24
30
  raise Error, "must provide block to after_commit" unless block
25
31
  synchronize(opts[:server]) do |conn|
26
- if h = _trans(conn)
32
+ if (h = _trans(conn)) && h[:in_after_commit].nil?
27
33
  raise Error, "cannot call after_commit in a prepared transaction" if h[:prepare]
28
34
  level = savepoint_level(conn)
29
35
  hooks = h[:after_commit] ||= {}
@@ -1,5 +1,5 @@
1
1
  module Sequel
2
2
  module TestAfterCommit
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
@@ -86,6 +86,41 @@ describe Sequel::TestAfterCommit do
86
86
  @callbacks.should == [:second_after_commit, :third_after_commit, :first_after_commit]
87
87
  end
88
88
 
89
+ it "should run new after_commit callbacks immediately when in the after_commit stage" do
90
+ @db.transaction do
91
+ @db.after_commit do
92
+ @db.after_commit { @callbacks << :after_commit_1_1 }
93
+ @callbacks << :after_commit_1
94
+ @db.after_commit { @callbacks << :after_commit_1_2 }
95
+ end
96
+ @callbacks.should == []
97
+
98
+ @db.transaction :savepoint => true do
99
+ @db.after_commit do
100
+ @db.after_commit { @callbacks << :after_commit_2_1 }
101
+ @callbacks << :after_commit_2
102
+ @db.after_commit { @callbacks << :after_commit_2_2 }
103
+ end
104
+ @callbacks.should == []
105
+ end
106
+
107
+ @callbacks.should == [:after_commit_2_1, :after_commit_2, :after_commit_2_2]
108
+
109
+ @db.transaction :savepoint => true do
110
+ @db.after_commit do
111
+ @db.after_commit { @callbacks << :after_commit_3_1 }
112
+ @callbacks << :after_commit_3
113
+ @db.after_commit { @callbacks << :after_commit_3_2 }
114
+ end
115
+ @callbacks.should == [:after_commit_2_1, :after_commit_2, :after_commit_2_2]
116
+ end
117
+
118
+ @callbacks.should == [:after_commit_2_1, :after_commit_2, :after_commit_2_2, :after_commit_3_1, :after_commit_3, :after_commit_3_2]
119
+ end
120
+
121
+ @callbacks.should == [:after_commit_2_1, :after_commit_2, :after_commit_2_2, :after_commit_3_1, :after_commit_3, :after_commit_3_2, :after_commit_1_1, :after_commit_1, :after_commit_1_2]
122
+ end
123
+
89
124
  it "should run after_rollback callbacks after the subtransaction in which they are declared rolls back" do
90
125
  @db.transaction do
91
126
  @db.after_commit { @callbacks << :first_after_commit }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_test_after_commit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hanks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-28 00:00:00.000000000 Z
11
+ date: 2014-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -61,6 +61,7 @@ extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
63
  - .gitignore
64
+ - CHANGELOG.md
64
65
  - Gemfile
65
66
  - LICENSE.txt
66
67
  - README.md