janus-ar 8.0.0 → 8.0.1
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/.github/workflows/ci.yml +67 -59
- data/.gitignore +1 -0
- data/.rubocop.yml +29 -26
- data/Gemfile.lock +142 -125
- data/README.md +130 -131
- data/bin/release.sh +1 -0
- data/gemfiles/activerecord_8_0.gemfile +7 -0
- data/gemfiles/activerecord_8_1.gemfile +7 -0
- data/janus-ar.gemspec +36 -36
- data/lib/janus-ar/active_record/connection_adapters/janus_mysql2_adapter.rb +32 -149
- data/lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb +32 -149
- data/lib/janus-ar/adapter_extensions.rb +107 -0
- data/lib/janus-ar/context.rb +79 -80
- data/lib/janus-ar/query_director.rb +81 -54
- data/lib/janus-ar/railtie.rb +15 -0
- data/lib/janus-ar/version.rb +17 -17
- data/lib/janus-ar.rb +24 -22
- data/spec/lib/janus-ar/active_record/connection_adapters/janus_mysql_adapter_spec.rb +78 -82
- data/spec/lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter_spec.rb +77 -82
- data/spec/lib/janus-ar/context_spec.rb +118 -46
- data/spec/lib/janus-ar/db_console_config_spec.rb +28 -0
- data/spec/lib/janus-ar/logging/subscriber_spec.rb +58 -0
- data/spec/lib/janus-ar/query_director_spec.rb +141 -59
- data/spec/shared_examples/a_mysql_like_server.rb +70 -0
- metadata +13 -10
|
@@ -1,82 +1,78 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe ActiveRecord::ConnectionAdapters::JanusMysql2Adapter do
|
|
4
|
-
subject { described_class.new(config) }
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
it_behaves_like 'a mysql like server'
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe ActiveRecord::ConnectionAdapters::JanusMysql2Adapter do
|
|
4
|
+
subject { described_class.new(config) }
|
|
5
|
+
|
|
6
|
+
let(:database) { 'test' }
|
|
7
|
+
let(:primary_config) do
|
|
8
|
+
{
|
|
9
|
+
'username' => 'primary',
|
|
10
|
+
'password' => 'primary_password',
|
|
11
|
+
'host' => '127.0.0.1',
|
|
12
|
+
'ssl' => true,
|
|
13
|
+
'ssl_mode' => 'REQUIRED',
|
|
14
|
+
'tls_min_version' => 3,
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
let(:replica_config) do
|
|
18
|
+
{
|
|
19
|
+
'username' => 'replica',
|
|
20
|
+
'password' => 'replica_password',
|
|
21
|
+
'host' => '127.0.0.1',
|
|
22
|
+
'pool' => 500,
|
|
23
|
+
'ssl' => true,
|
|
24
|
+
'ssl_mode' => 'REQUIRED',
|
|
25
|
+
'tls_min_version' => 3,
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
let(:config) do
|
|
29
|
+
{
|
|
30
|
+
database:,
|
|
31
|
+
adapter: 'janus_mysql2',
|
|
32
|
+
janus: {
|
|
33
|
+
'primary' => primary_config,
|
|
34
|
+
'replica' => replica_config,
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe 'Configuration' do
|
|
40
|
+
it 'creates primary connection as expected' do
|
|
41
|
+
config = primary_config.dup.freeze
|
|
42
|
+
expect(subject.config).to eq config.merge('database' => database,
|
|
43
|
+
'flags' => ::Janus::Client::FOUND_ROWS).symbolize_keys
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'creates replica connection as expected' do
|
|
47
|
+
config = replica_config.dup.freeze
|
|
48
|
+
expect(
|
|
49
|
+
subject.replica_connection.instance_variable_get(:@config)
|
|
50
|
+
).to eq config.merge('database' => database, 'flags' => ::Janus::Client::FOUND_ROWS).symbolize_keys
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
context 'Rails sets empty database for server connection' do
|
|
54
|
+
let(:database) { nil }
|
|
55
|
+
|
|
56
|
+
it 'creates primary connection as expected' do
|
|
57
|
+
config = primary_config.dup.freeze
|
|
58
|
+
expect(subject.config).to eq config.merge(
|
|
59
|
+
'database' => nil,
|
|
60
|
+
'flags' => ::Janus::Client::FOUND_ROWS
|
|
61
|
+
).symbolize_keys
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'creates replica connection as expected' do
|
|
65
|
+
config = replica_config.dup.freeze
|
|
66
|
+
expect(
|
|
67
|
+
subject.replica_connection.instance_variable_get(:@config)
|
|
68
|
+
).to eq config.merge('database' => nil, 'flags' => ::Janus::Client::FOUND_ROWS).symbolize_keys
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe 'Integration tests' do
|
|
74
|
+
let(:table_name) { 'table_name_mysql2' }
|
|
75
|
+
|
|
76
|
+
it_behaves_like 'a mysql like server'
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -1,82 +1,77 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe ActiveRecord::ConnectionAdapters::JanusTrilogyAdapter do
|
|
4
|
-
subject { described_class.new(config) }
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
config
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
let(:table_name) { 'table_name_trilogy' }
|
|
79
|
-
|
|
80
|
-
it_behaves_like 'a mysql like server'
|
|
81
|
-
end
|
|
82
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe ActiveRecord::ConnectionAdapters::JanusTrilogyAdapter do
|
|
4
|
+
subject { described_class.new(config) }
|
|
5
|
+
|
|
6
|
+
let(:database) { 'test' }
|
|
7
|
+
let(:primary_config) do
|
|
8
|
+
{
|
|
9
|
+
'username' => 'primary',
|
|
10
|
+
'password' => 'primary_password',
|
|
11
|
+
'host' => '127.0.0.1',
|
|
12
|
+
'ssl' => true,
|
|
13
|
+
'ssl_mode' => 'REQUIRED',
|
|
14
|
+
'tls_min_version' => Trilogy::TLS_VERSION_12,
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
let(:replica_config) do
|
|
18
|
+
{
|
|
19
|
+
'username' => 'replica',
|
|
20
|
+
'password' => 'replica_password',
|
|
21
|
+
'host' => '127.0.0.1',
|
|
22
|
+
'pool' => 500,
|
|
23
|
+
'ssl' => true,
|
|
24
|
+
'ssl_mode' => 'REQUIRED',
|
|
25
|
+
'tls_min_version' => Trilogy::TLS_VERSION_12,
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
let(:config) do
|
|
29
|
+
{
|
|
30
|
+
database:,
|
|
31
|
+
adapter: 'janus_trilogy',
|
|
32
|
+
janus: {
|
|
33
|
+
'primary' => primary_config,
|
|
34
|
+
'replica' => replica_config,
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe 'Configuration' do
|
|
40
|
+
# Trilogy enables FOUND_ROWS via the `found_rows` option (not mysql2-style
|
|
41
|
+
# flags), and ActiveRecord's TrilogyAdapter forces it on. We assert it is
|
|
42
|
+
# present even though the supplied config omits it.
|
|
43
|
+
it 'creates primary connection as expected' do
|
|
44
|
+
config = primary_config.dup.freeze
|
|
45
|
+
expect(subject.config).to eq config.merge('database' => database, 'found_rows' => true).symbolize_keys
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'creates replica connection as expected' do
|
|
49
|
+
config = replica_config.dup.freeze
|
|
50
|
+
expect(
|
|
51
|
+
subject.replica_connection.instance_variable_get(:@config)
|
|
52
|
+
).to eq config.merge('database' => database, 'found_rows' => true).symbolize_keys
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context 'Rails sets empty database for server connection' do
|
|
56
|
+
let(:database) { nil }
|
|
57
|
+
|
|
58
|
+
it 'creates primary connection as expected' do
|
|
59
|
+
config = primary_config.dup.freeze
|
|
60
|
+
expect(subject.config).to eq config.merge('database' => nil, 'found_rows' => true).symbolize_keys
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'creates replica connection as expected' do
|
|
64
|
+
config = replica_config.dup.freeze
|
|
65
|
+
expect(
|
|
66
|
+
subject.replica_connection.instance_variable_get(:@config)
|
|
67
|
+
).to eq config.merge('database' => nil, 'found_rows' => true).symbolize_keys
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe 'Integration tests' do
|
|
73
|
+
let(:table_name) { 'table_name_trilogy' }
|
|
74
|
+
|
|
75
|
+
it_behaves_like 'a mysql like server'
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -1,46 +1,118 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'janus-ar/context'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
context
|
|
25
|
-
expect(context).to
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
context
|
|
33
|
-
context.release_all
|
|
34
|
-
expect(context.use_primary?).to be false
|
|
35
|
-
expect(context.last_used_connection).to be_nil
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
describe '#used_connection' do
|
|
40
|
-
it 'sets the last used connection' do
|
|
41
|
-
context = described_class.new
|
|
42
|
-
context.used_connection(:
|
|
43
|
-
expect(context.last_used_connection).to eq(:
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'janus-ar/context'
|
|
4
|
+
require 'active_support/executor'
|
|
5
|
+
|
|
6
|
+
RSpec.describe Janus::Context do
|
|
7
|
+
after(:each) { described_class.release_all }
|
|
8
|
+
|
|
9
|
+
describe '#initialize' do
|
|
10
|
+
it 'defaults to the replica and a primary last-used connection' do
|
|
11
|
+
context = described_class.new
|
|
12
|
+
expect(context.use_primary?).to be false
|
|
13
|
+
expect(context.last_used_connection).to eq(:primary)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'can be created pinned to the primary' do
|
|
17
|
+
expect(described_class.new(primary: true).use_primary?).to be true
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '#stick_to_primary' do
|
|
22
|
+
it 'sets the primary flag to true' do
|
|
23
|
+
context = described_class.new
|
|
24
|
+
context.stick_to_primary
|
|
25
|
+
expect(context.use_primary?).to be true
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '#release_all' do
|
|
30
|
+
it 'resets the primary flag and the last used connection' do
|
|
31
|
+
context = described_class.new(primary: true)
|
|
32
|
+
context.used_connection(:primary)
|
|
33
|
+
context.release_all
|
|
34
|
+
expect(context.use_primary?).to be false
|
|
35
|
+
expect(context.last_used_connection).to be_nil
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '#used_connection' do
|
|
40
|
+
it 'sets the last used connection' do
|
|
41
|
+
context = described_class.new
|
|
42
|
+
context.used_connection(:replica)
|
|
43
|
+
expect(context.last_used_connection).to eq(:replica)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe 'class-level access' do
|
|
48
|
+
it 'sticks and releases the current execution state' do
|
|
49
|
+
described_class.stick_to_primary
|
|
50
|
+
expect(described_class.use_primary?).to be true
|
|
51
|
+
described_class.release_all
|
|
52
|
+
expect(described_class.use_primary?).to be false
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'isolates state between threads' do
|
|
56
|
+
described_class.stick_to_primary
|
|
57
|
+
other = Thread.new { described_class.use_primary? }.value
|
|
58
|
+
expect(other).to be false
|
|
59
|
+
expect(described_class.use_primary?).to be true
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'isolates the last used connection between threads' do
|
|
63
|
+
described_class.used_connection(:replica)
|
|
64
|
+
other = Thread.new do
|
|
65
|
+
described_class.used_connection(:primary)
|
|
66
|
+
described_class.last_used_connection
|
|
67
|
+
end.value
|
|
68
|
+
expect(other).to eq(:primary)
|
|
69
|
+
expect(described_class.last_used_connection).to eq(:replica)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'is safe to release a context that was never touched' do
|
|
73
|
+
Thread.new do
|
|
74
|
+
expect { described_class.release_all }.not_to raise_error
|
|
75
|
+
expect(described_class.use_primary?).to be false
|
|
76
|
+
end.join
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe '.install_reset_hook' do
|
|
81
|
+
let(:executor) { Class.new(ActiveSupport::Executor) }
|
|
82
|
+
|
|
83
|
+
it 'releases the context at the start of every executor run' do
|
|
84
|
+
described_class.install_reset_hook(executor)
|
|
85
|
+
described_class.stick_to_primary
|
|
86
|
+
|
|
87
|
+
stuck_inside = nil
|
|
88
|
+
executor.wrap { stuck_inside = described_class.use_primary? }
|
|
89
|
+
|
|
90
|
+
expect(stuck_inside).to be false
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'stops stickiness leaking from a previous run into the next' do
|
|
94
|
+
described_class.install_reset_hook(executor)
|
|
95
|
+
|
|
96
|
+
executor.wrap { described_class.stick_to_primary }
|
|
97
|
+
|
|
98
|
+
leaked = nil
|
|
99
|
+
executor.wrap { leaked = described_class.use_primary? }
|
|
100
|
+
expect(leaked).to be false
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'still starts the next run clean after the previous run raised' do
|
|
104
|
+
described_class.install_reset_hook(executor)
|
|
105
|
+
|
|
106
|
+
expect do
|
|
107
|
+
executor.wrap do
|
|
108
|
+
described_class.stick_to_primary
|
|
109
|
+
raise 'boom'
|
|
110
|
+
end
|
|
111
|
+
end.to raise_error('boom')
|
|
112
|
+
|
|
113
|
+
leaked = nil
|
|
114
|
+
executor.wrap { leaked = described_class.use_primary? }
|
|
115
|
+
expect(leaked).to be false
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'janus-ar/db_console_config'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Janus::DbConsoleConfig do
|
|
6
|
+
subject(:console_config) { described_class.new(db_config) }
|
|
7
|
+
|
|
8
|
+
let(:db_config) do
|
|
9
|
+
instance_double(
|
|
10
|
+
ActiveRecord::DatabaseConfigurations::HashConfig,
|
|
11
|
+
configuration_hash: {
|
|
12
|
+
database: 'my_database',
|
|
13
|
+
janus: {
|
|
14
|
+
'primary' => { 'host' => 'primary.local', 'username' => 'primary' },
|
|
15
|
+
'replica' => { 'host' => 'replica.local', 'username' => 'replica' },
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'exposes the replica configuration with symbol keys so dbconsole connects to a replica' do
|
|
22
|
+
expect(console_config.configuration_hash).to eq(host: 'replica.local', username: 'replica')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'exposes the database name from the top-level config' do
|
|
26
|
+
expect(console_config.database).to eq('my_database')
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'janus-ar/context'
|
|
4
|
+
require 'janus-ar/logging/subscriber'
|
|
5
|
+
|
|
6
|
+
RSpec.describe Janus::Logging::Subscriber do
|
|
7
|
+
# A minimal stand-in for ActiveRecord::LogSubscriber: it records the event it
|
|
8
|
+
# is given so we can assert on the (possibly rewritten) payload name.
|
|
9
|
+
let(:base_class) do
|
|
10
|
+
Class.new do
|
|
11
|
+
attr_reader :received_event
|
|
12
|
+
|
|
13
|
+
def sql(event)
|
|
14
|
+
@received_event = event
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
let(:subscriber) { base_class.new.extend(described_class) }
|
|
19
|
+
let(:event) { instance_double(ActiveSupport::Notifications::Event, payload: { name: 'User Load' }) }
|
|
20
|
+
|
|
21
|
+
after(:each) { Janus::Context.release_all }
|
|
22
|
+
|
|
23
|
+
it 'tags the log name with the last used connection' do
|
|
24
|
+
Janus::Context.used_connection(:replica)
|
|
25
|
+
|
|
26
|
+
subscriber.sql(event)
|
|
27
|
+
|
|
28
|
+
expect(event.payload[:name]).to eq('[replica] User Load')
|
|
29
|
+
expect(subscriber.received_event).to eq(event)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'reflects the primary connection' do
|
|
33
|
+
Janus::Context.used_connection(:primary)
|
|
34
|
+
|
|
35
|
+
subscriber.sql(event)
|
|
36
|
+
|
|
37
|
+
expect(event.payload[:name]).to eq('[primary] User Load')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'leaves the name unchanged when no connection has been used yet' do
|
|
41
|
+
Janus::Context.release_all
|
|
42
|
+
|
|
43
|
+
subscriber.sql(event)
|
|
44
|
+
|
|
45
|
+
expect(event.payload[:name]).to eq('User Load')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
Janus::Logging::Subscriber::IGNORE_PAYLOAD_NAMES.each do |ignored|
|
|
49
|
+
it "does not tag #{ignored} statements" do
|
|
50
|
+
Janus::Context.used_connection(:replica)
|
|
51
|
+
ignored_event = instance_double(ActiveSupport::Notifications::Event, payload: { name: ignored })
|
|
52
|
+
|
|
53
|
+
subscriber.sql(ignored_event)
|
|
54
|
+
|
|
55
|
+
expect(ignored_event.payload[:name]).to eq(ignored)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|