ar_transaction_changes 1.1.10 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ar_transaction_changes/version.rb +1 -1
- data/lib/ar_transaction_changes.rb +23 -23
- data/test/transaction_changes_test.rb +0 -24
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c1ad6773a9205c5481c708ac6685c0f0609018fb0bc03845b57db109a32bd6b3
|
|
4
|
+
data.tar.gz: a4df65cd09d591fefb68fa9c3b1ccf311fbffcafb42e7ac7192622d747e05d49
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f51346e32137f229013ccaf2f201e6d2ec2c60a806fb92f452818c1cf8d553a13f45744d17b0a0b8bff33496455611451443aa81f7f780826fa4b546fb91394e
|
|
7
|
+
data.tar.gz: 4c7200f2d0dcbe341fda292fe71a916dd072c52a617c992c5140abb203765d4ce1b456efa67a20bf8ba3c310ea1038c90486424fce9b6e1844c91920c5910fbf
|
|
@@ -4,37 +4,37 @@ require "ar_transaction_changes/version"
|
|
|
4
4
|
require "active_record"
|
|
5
5
|
|
|
6
6
|
module ArTransactionChanges
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if !base._commit_callbacks.empty? || !base._rollback_callbacks.empty?
|
|
10
|
-
raise "ArTransactionChanges must be included before defining any after_commit or after_rollback callbacks"
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
if ActiveRecord.version >= Gem::Version.new('8.1.0.alpha')
|
|
16
|
-
def _run_commit_callbacks!
|
|
7
|
+
if ActiveRecord.version >= Gem::Version.new('7.1')
|
|
8
|
+
def run_callbacks(kind, type = nil)
|
|
17
9
|
super
|
|
18
10
|
ensure
|
|
19
|
-
|
|
11
|
+
if kind == :commit || kind == :rollback
|
|
12
|
+
@transaction_changed_attributes = nil
|
|
13
|
+
end
|
|
20
14
|
end
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
if ActiveRecord.version >= Gem::Version.new('8.1.0.alpha')
|
|
17
|
+
# We should reset @transaction_changed_attributes in the no-op version of the method.
|
|
18
|
+
# Even if there are no callbacks registered, attributes should be reset on commit/rollback.
|
|
19
|
+
def _run_commit_callbacks
|
|
20
|
+
super
|
|
21
|
+
ensure
|
|
22
|
+
@transaction_changed_attributes = nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def _run_rollback_callbacks
|
|
26
|
+
super
|
|
27
|
+
ensure
|
|
28
|
+
@transaction_changed_attributes = nil
|
|
29
|
+
end
|
|
26
30
|
end
|
|
27
31
|
else
|
|
28
|
-
def
|
|
32
|
+
def run_callbacks(kind)
|
|
29
33
|
super
|
|
30
34
|
ensure
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def _run_rollback_callbacks
|
|
35
|
-
super
|
|
36
|
-
ensure
|
|
37
|
-
@transaction_changed_attributes = nil
|
|
35
|
+
if kind == :commit || kind == :rollback
|
|
36
|
+
@transaction_changed_attributes = nil
|
|
37
|
+
end
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -174,28 +174,4 @@ class TransactionChangesTest < Minitest::Test
|
|
|
174
174
|
|
|
175
175
|
assert_equal [[], ['a', 'b']], @user.stored_transaction_changes['notes']
|
|
176
176
|
end
|
|
177
|
-
|
|
178
|
-
def test_do_not_allow_adding_this_gem_to_a_model_after_commit_callbacks_are_defined
|
|
179
|
-
assert_raises(RuntimeError) do
|
|
180
|
-
Class.new(ActiveRecord::Base) do
|
|
181
|
-
after_commit :some_method
|
|
182
|
-
|
|
183
|
-
include ArTransactionChanges
|
|
184
|
-
|
|
185
|
-
def some_method; end
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
def test_do_not_allow_adding_this_gem_to_a_model_after_rollback_callbacks_are_defined
|
|
191
|
-
assert_raises(RuntimeError) do
|
|
192
|
-
Class.new(ActiveRecord::Base) do
|
|
193
|
-
after_rollback :some_method
|
|
194
|
-
|
|
195
|
-
include ArTransactionChanges
|
|
196
|
-
|
|
197
|
-
def some_method; end
|
|
198
|
-
end
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
177
|
end
|