isolator 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/isolator/adapter_builder.rb +2 -1
- data/lib/isolator/adapters/http/webmock.rb +2 -1
- data/lib/isolator/database_cleaner_support.rb +10 -3
- data/lib/isolator/orm_adapters/active_support_subscriber.rb +4 -2
- data/lib/isolator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f7e62d7f280c06f8ad704770d5ba5f14198006bccec0ce69e0e1aa99a8b32c7
|
4
|
+
data.tar.gz: 4c4aabcfad57d3ba2da54b5e75b7ee057bf25a10d382094d05a04fec2f371c85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 565c283a6ddebe9e7d39472094f44f346a1ea1b49afc5ad9fe7aee1ecb98e5910fd5cdc4c0804c581132363338e39465faadab3f51eccbddaea8f731225fd364
|
7
|
+
data.tar.gz: ab01a1494c0fac2c1920bced02ae86c6b6b26a6e420f3ef6e43fdd1bd300e14e259c3353b9af08b14787b5ebe499d816222998e837d0af4e16006d9c77a9f5d1
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.10.0 (2023-08-15)
|
6
|
+
|
7
|
+
- Support multiple databases with DatabaseCleaner. ([@palkan][])
|
8
|
+
|
9
|
+
- Fix query having invalid characters. ([@tagirahmad][])
|
10
|
+
|
11
|
+
Fixes [#43](https://github.com/palkan/isolator/issues/43).
|
12
|
+
|
5
13
|
## 0.9.0 (2023-05-18)
|
6
14
|
|
7
15
|
- Support keyword arguments to isolated method in Ruby 3.0. ([@Mange][])
|
@@ -109,3 +117,5 @@ This, for example, makes Isolator compatible with Rails multi-database apps.
|
|
109
117
|
[@mquan]: https://github.com/mquan
|
110
118
|
[@bobbymcwho]: https://github.com/bobbymcwho
|
111
119
|
[@Mange]: https://github.com/Mange
|
120
|
+
[@tomgi]: https://github.com/tomgi
|
121
|
+
[@tagirahmad]: https://github.com/tagirahmad
|
@@ -33,7 +33,8 @@ module Isolator
|
|
33
33
|
|
34
34
|
Module.new do
|
35
35
|
define_method method_name do |*args, **kwargs, &block|
|
36
|
-
|
36
|
+
# check if we are even notifying before calling `caller`, which is well known to be slow
|
37
|
+
adapter.notify(caller, self, *args, **kwargs) if adapter.notify?(*args, **kwargs)
|
37
38
|
super(*args, **kwargs, &block)
|
38
39
|
end
|
39
40
|
end
|
@@ -1,16 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "database_cleaner/active_record/transaction"
|
4
|
-
|
5
4
|
::DatabaseCleaner::ActiveRecord::Transaction.prepend(
|
6
5
|
Module.new do
|
7
6
|
def start
|
8
7
|
super
|
9
|
-
|
8
|
+
connection_id = connection_class.connection.object_id
|
9
|
+
Isolator.set_connection_threshold(
|
10
|
+
Isolator.transactions_threshold(connection_id) + 1,
|
11
|
+
connection_id
|
12
|
+
)
|
10
13
|
end
|
11
14
|
|
12
15
|
def clean
|
13
|
-
|
16
|
+
connection_id = connection_class.connection.object_id
|
17
|
+
Isolator.set_connection_threshold(
|
18
|
+
Isolator.transactions_threshold(connection_id) - 1,
|
19
|
+
connection_id
|
20
|
+
)
|
14
21
|
super
|
15
22
|
end
|
16
23
|
end
|
@@ -10,8 +10,10 @@ module Isolator
|
|
10
10
|
def self.subscribe!(event)
|
11
11
|
::ActiveSupport::Notifications.subscribe(event) do |_name, _start, _finish, _id, query|
|
12
12
|
connection_id = query[:connection_id] || query[:connection]&.object_id || 0
|
13
|
-
|
14
|
-
|
13
|
+
# Prevents "ArgumentError: invalid byte sequence in UTF-8" by replacing invalid byte sequence with "?"
|
14
|
+
sanitized_query = query[:sql].encode("UTF-8", "binary", invalid: :replace, undef: :replace, replace: "?")
|
15
|
+
Isolator.incr_transactions!(connection_id) if START_PATTERN.match?(sanitized_query)
|
16
|
+
Isolator.decr_transactions!(connection_id) if FINISH_PATTERN.match?(sanitized_query)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
data/lib/isolator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isolator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sniffer
|