liveqa 1.8.3 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -2
- data/.travis.yml +0 -1
- data/LICENCE +21 -0
- data/README.md +10 -117
- data/lib/liveqa/api_resource.rb +7 -3
- data/lib/liveqa/batch.rb +18 -0
- data/lib/liveqa/config.rb +13 -21
- data/lib/liveqa/event.rb +1 -1
- data/lib/liveqa/formated_logger.rb +45 -0
- data/lib/liveqa/message.rb +3 -3
- data/lib/liveqa/plugins/rack/middleware.rb +3 -3
- data/lib/liveqa/plugins/sidekiq/server_middleware.rb +1 -1
- data/lib/liveqa/processor/async.rb +48 -0
- data/lib/liveqa/processor/batch.rb +81 -0
- data/lib/liveqa/processor/worker.rb +66 -0
- data/lib/liveqa/util.rb +3 -3
- data/lib/liveqa/version.rb +1 -1
- data/lib/liveqa.rb +66 -33
- data/liveqa.gemspec +3 -3
- data/spec/lib/liveqa/api_resource_spec.rb +8 -8
- data/spec/lib/liveqa/batch_spec.rb +14 -0
- data/spec/lib/liveqa/config_spec.rb +9 -15
- data/spec/lib/liveqa/formated_logger_spec.rb +99 -0
- data/spec/lib/liveqa/processor/async_spec.rb +19 -0
- data/spec/lib/liveqa/processor/batch_spec.rb +48 -0
- data/spec/lib/liveqa/processor/worker_spec.rb +25 -0
- data/spec/lib/liveqa_spec.rb +133 -40
- metadata +26 -16
- data/lib/liveqa/async_handlers/base.rb +0 -15
- data/lib/liveqa/async_handlers/sidekiq.rb +0 -33
- data/spec/lib/liveqa/async_handlers/base_spec.rb +0 -29
- data/spec/lib/liveqa/async_handlers/sidekiq_spec.rb +0 -40
data/spec/lib/liveqa_spec.rb
CHANGED
@@ -7,9 +7,6 @@ describe LiveQA::Event do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
describe '.track' do
|
10
|
-
let(:response) { double('LiveQA::Event', successful?: true) }
|
11
|
-
after { LiveQA.track('test', { user_id: 42, properties: { total: 10 }}, { no_ssl: true }) }
|
12
|
-
|
13
10
|
let(:expected_arg) {{
|
14
11
|
user_id: 42,
|
15
12
|
type: 'track',
|
@@ -30,20 +27,39 @@ describe LiveQA::Event do
|
|
30
27
|
pid: kind_of(Numeric)
|
31
28
|
},
|
32
29
|
}}
|
30
|
+
let(:response) { double('LiveQA::Event', successful?: true) }
|
31
|
+
|
32
|
+
context 'async' do
|
33
|
+
let(:processor_mock) { double('Processor', enqueue: true) }
|
34
|
+
before do
|
35
|
+
allow(LiveQA).to receive(:processor).and_return(processor_mock)
|
36
|
+
LiveQA.track('test', { user_id: 42, properties: { total: 10 }}, no_ssl: true, space_name: 'test')
|
37
|
+
end
|
38
|
+
|
39
|
+
it { expect(processor_mock).to have_received(:enqueue).with(action: 'events:create', payload: hash_including(expected_arg), options: { space_name: 'test' }) }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'without async' do
|
43
|
+
before do
|
44
|
+
LiveQA.configurations.async = false
|
45
|
+
allow(LiveQA::Event).to receive(:create).and_return(response)
|
46
|
+
LiveQA.track('test', { user_id: 42, properties: { total: 10 }}, no_ssl: true, space_name: 'test')
|
47
|
+
end
|
33
48
|
|
34
|
-
|
49
|
+
it { expect(LiveQA::Event).to have_received(:create).with(hash_including(expected_arg), { no_ssl: true, space_name: 'test' }) }
|
50
|
+
end
|
35
51
|
|
36
52
|
context 'not enabled' do
|
37
|
-
before
|
53
|
+
before do
|
54
|
+
LiveQA.configurations.enabled = false
|
55
|
+
LiveQA.track('test', { user_id: 42, properties: { total: 10 }}, no_ssl: true, space_name: 'test')
|
56
|
+
end
|
38
57
|
|
39
58
|
it { expect(LiveQA::Event).to_not receive(:create) }
|
40
59
|
end
|
41
60
|
end
|
42
61
|
|
43
62
|
describe '.identify' do
|
44
|
-
let(:response) { double('LiveQA::Event', successful?: true) }
|
45
|
-
after { LiveQA.identify(42, { tracker_id: 'xx', properties: { name: 'John Doe' }}, { no_ssl: true }) }
|
46
|
-
|
47
63
|
let(:expected_arg) {{
|
48
64
|
tracker_id: 'xx',
|
49
65
|
properties: {
|
@@ -64,20 +80,39 @@ describe LiveQA::Event do
|
|
64
80
|
pid: kind_of(Numeric)
|
65
81
|
},
|
66
82
|
}}
|
83
|
+
let(:response) { double('LiveQA::Event', successful?: true) }
|
84
|
+
|
85
|
+
context 'async' do
|
86
|
+
let(:processor_mock) { double('Processor', enqueue: true) }
|
87
|
+
before do
|
88
|
+
allow(LiveQA).to receive(:processor).and_return(processor_mock)
|
89
|
+
LiveQA.identify(42, { tracker_id: 'xx', properties: { name: 'John Doe' }}, no_ssl: true, space_name: 'test')
|
90
|
+
end
|
91
|
+
|
92
|
+
it { expect(processor_mock).to have_received(:enqueue).with(action: 'events:create', payload: hash_including(expected_arg), options: { space_name: 'test' }) }
|
93
|
+
end
|
67
94
|
|
68
|
-
|
95
|
+
context 'without async' do
|
96
|
+
before do
|
97
|
+
LiveQA.configurations.async = false
|
98
|
+
allow(LiveQA::Event).to receive(:create).and_return(response)
|
99
|
+
LiveQA.identify(42, { tracker_id: 'xx', properties: { name: 'John Doe' }}, no_ssl: true, space_name: 'test')
|
100
|
+
end
|
101
|
+
|
102
|
+
it { expect(LiveQA::Event).to have_received(:create).with(hash_including(expected_arg), { no_ssl: true, space_name: 'test' }) }
|
103
|
+
end
|
69
104
|
|
70
105
|
context 'not enabled' do
|
71
|
-
before
|
106
|
+
before do
|
107
|
+
LiveQA.configurations.enabled = false
|
108
|
+
LiveQA.identify(42, { tracker_id: 'xx', properties: { name: 'John Doe' }}, no_ssl: true, space_name: 'test')
|
109
|
+
end
|
72
110
|
|
73
111
|
it { expect(LiveQA::Event).to_not receive(:create) }
|
74
112
|
end
|
75
113
|
end
|
76
114
|
|
77
115
|
describe '.set_group' do
|
78
|
-
let(:response) { double('LiveQA::Group', successful?: true) }
|
79
|
-
after { LiveQA.set_group(42, { properties: { name: 'John Group' }}, { no_ssl: true }) }
|
80
|
-
|
81
116
|
let(:expected_arg) {{
|
82
117
|
properties: {
|
83
118
|
name: 'John Group'
|
@@ -86,20 +121,39 @@ describe LiveQA::Event do
|
|
86
121
|
timestamp: kind_of(String),
|
87
122
|
session_tracker_id: kind_of(String),
|
88
123
|
}}
|
124
|
+
let(:response) { double('LiveQA::Group', successful?: true) }
|
125
|
+
|
126
|
+
context 'async' do
|
127
|
+
let(:processor_mock) { double('Processor', enqueue: true) }
|
128
|
+
before do
|
129
|
+
allow(LiveQA).to receive(:processor).and_return(processor_mock)
|
130
|
+
LiveQA.set_group(42, { properties: { name: 'John Group' }}, no_ssl: true, space_name: 'test')
|
131
|
+
end
|
89
132
|
|
90
|
-
|
133
|
+
it { expect(processor_mock).to have_received(:enqueue).with(action: 'groups:update', id: 42, payload: hash_including(expected_arg), options: { space_name: 'test' }) }
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'without async' do
|
137
|
+
before do
|
138
|
+
LiveQA.configurations.async = false
|
139
|
+
allow(LiveQA::Group).to receive(:update).and_return(response)
|
140
|
+
LiveQA.set_group(42, { properties: { name: 'John Group' }}, no_ssl: true, space_name: 'test')
|
141
|
+
end
|
142
|
+
|
143
|
+
it { expect(LiveQA::Group).to have_received(:update).with(42, hash_including(expected_arg), { no_ssl: true, space_name: 'test' }) }
|
144
|
+
end
|
91
145
|
|
92
146
|
context 'not enabled' do
|
93
|
-
before
|
147
|
+
before do
|
148
|
+
LiveQA.configurations.enabled = false
|
149
|
+
LiveQA.set_group(42, { properties: { name: 'John Group' }}, no_ssl: true, space_name: 'test')
|
150
|
+
end
|
94
151
|
|
95
152
|
it { expect(LiveQA::Group).to_not receive(:update) }
|
96
153
|
end
|
97
154
|
end
|
98
155
|
|
99
156
|
describe '.set_identity' do
|
100
|
-
let(:response) { double('LiveQA::Identity', successful?: true) }
|
101
|
-
after { LiveQA.set_identity(42, { properties: { name: 'John Doe' }}, { no_ssl: true }) }
|
102
|
-
|
103
157
|
let(:expected_arg) {{
|
104
158
|
properties: {
|
105
159
|
name: 'John Doe'
|
@@ -108,37 +162,78 @@ describe LiveQA::Event do
|
|
108
162
|
timestamp: kind_of(String),
|
109
163
|
session_tracker_id: kind_of(String),
|
110
164
|
}}
|
165
|
+
let(:response) { double('LiveQA::Identity', successful?: true) }
|
111
166
|
|
112
|
-
|
167
|
+
context 'async' do
|
168
|
+
let(:processor_mock) { double('Processor', enqueue: true) }
|
169
|
+
before do
|
170
|
+
allow(LiveQA).to receive(:processor).and_return(processor_mock)
|
171
|
+
LiveQA.set_identity(42, { properties: { name: 'John Doe' }}, no_ssl: true, space_name: 'test')
|
172
|
+
end
|
173
|
+
|
174
|
+
it { expect(processor_mock).to have_received(:enqueue).with(action: 'identities:update', id: 42, payload: hash_including(expected_arg), options: { space_name: 'test' }) }
|
175
|
+
end
|
176
|
+
|
177
|
+
context 'without async' do
|
178
|
+
before do
|
179
|
+
LiveQA.configurations.async = false
|
180
|
+
allow(LiveQA::Identity).to receive(:update).and_return(response)
|
181
|
+
LiveQA.set_identity(42, { properties: { name: 'John Doe' }}, no_ssl: true, space_name: 'test')
|
182
|
+
end
|
183
|
+
|
184
|
+
it { expect(LiveQA::Identity).to have_received(:update).with(42, hash_including(expected_arg), { no_ssl: true, space_name: 'test' }) }
|
185
|
+
end
|
113
186
|
|
114
187
|
context 'not enabled' do
|
115
|
-
before
|
188
|
+
before do
|
189
|
+
LiveQA.configurations.enabled = false
|
190
|
+
LiveQA.set_identity(42, { properties: { name: 'John Doe' }}, no_ssl: true, space_name: 'test')
|
191
|
+
end
|
116
192
|
|
117
193
|
it { expect(LiveQA::Identity).to_not receive(:update) }
|
118
194
|
end
|
119
195
|
end
|
120
196
|
|
121
197
|
describe '.watch' do
|
198
|
+
let(:expected_arg) {{
|
199
|
+
template_flow: 'My Flow',
|
200
|
+
expected_times: 42,
|
201
|
+
message_id: kind_of(String),
|
202
|
+
timestamp: kind_of(String),
|
203
|
+
session_tracker_id: kind_of(String),
|
204
|
+
}}
|
122
205
|
let(:response) { double('LiveQA::Identity', successful?: true) }
|
123
206
|
|
207
|
+
context 'async' do
|
208
|
+
let(:processor_mock) { double('Processor', enqueue: true) }
|
209
|
+
before do
|
210
|
+
allow(LiveQA).to receive(:processor).and_return(processor_mock)
|
211
|
+
LiveQA.watch('My Flow', { expected_times: 42 }, no_ssl: true, space_name: 'test')
|
212
|
+
end
|
124
213
|
|
125
|
-
|
126
|
-
|
214
|
+
it { expect(processor_mock).to have_received(:enqueue).with(action: 'watchers:create', payload: hash_including(expected_arg), options: { space_name: 'test' }) }
|
215
|
+
end
|
127
216
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
}}
|
217
|
+
context 'without async' do
|
218
|
+
before do
|
219
|
+
LiveQA.configurations.async = false
|
220
|
+
allow(LiveQA::Watcher).to receive(:create).and_return(response)
|
221
|
+
LiveQA.watch('My Flow', { expected_times: 42 }, no_ssl: true, space_name: 'test')
|
222
|
+
end
|
135
223
|
|
136
|
-
it { expect(LiveQA::Watcher).to
|
224
|
+
it { expect(LiveQA::Watcher).to have_received(:create).with(hash_including(expected_arg), { no_ssl: true, space_name: 'test' }) }
|
137
225
|
end
|
138
226
|
|
139
|
-
context '
|
140
|
-
|
227
|
+
context 'not enabled' do
|
228
|
+
before do
|
229
|
+
LiveQA.configurations.enabled = false
|
230
|
+
LiveQA.watch('My Flow', { expected_times: 42 }, no_ssl: true, space_name: 'test')
|
231
|
+
end
|
141
232
|
|
233
|
+
it { expect(LiveQA::Watcher).to_not receive(:create) }
|
234
|
+
end
|
235
|
+
|
236
|
+
context 'without session' do
|
142
237
|
let(:expected_arg) {{
|
143
238
|
template_flow: 'My Flow',
|
144
239
|
expected_times: 42,
|
@@ -146,15 +241,13 @@ describe LiveQA::Event do
|
|
146
241
|
timestamp: kind_of(String),
|
147
242
|
}}
|
148
243
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
before { LiveQA.configurations.enabled = false }
|
244
|
+
let(:processor_mock) { double('Processor', enqueue: true) }
|
245
|
+
before do
|
246
|
+
allow(LiveQA).to receive(:processor).and_return(processor_mock)
|
247
|
+
LiveQA.watch('My Flow', { expected_times: 42, without_session: true }, no_ssl: true, space_name: 'test')
|
248
|
+
end
|
156
249
|
|
157
|
-
it { expect(
|
250
|
+
it { expect(processor_mock).to have_received(:enqueue).with(action: 'watchers:create', payload: hash_including(expected_arg), options: { space_name: 'test' }) }
|
158
251
|
end
|
159
252
|
end
|
160
253
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liveqa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LiveQA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faker
|
@@ -25,33 +25,33 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.8.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.9.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.9.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.58.2
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 0.58.2
|
83
83
|
description: LiveQA ruby integration
|
84
84
|
email:
|
85
85
|
- support@liveqa.io
|
@@ -94,17 +94,18 @@ files:
|
|
94
94
|
- ".travis.yml"
|
95
95
|
- CHANGELOG.md
|
96
96
|
- Gemfile
|
97
|
+
- LICENCE
|
97
98
|
- README.md
|
98
99
|
- Rakefile
|
99
100
|
- lib/liveqa.rb
|
100
101
|
- lib/liveqa/api_operation/delete.rb
|
101
102
|
- lib/liveqa/api_operation/save.rb
|
102
103
|
- lib/liveqa/api_resource.rb
|
103
|
-
- lib/liveqa/
|
104
|
-
- lib/liveqa/async_handlers/sidekiq.rb
|
104
|
+
- lib/liveqa/batch.rb
|
105
105
|
- lib/liveqa/config.rb
|
106
106
|
- lib/liveqa/errors.rb
|
107
107
|
- lib/liveqa/event.rb
|
108
|
+
- lib/liveqa/formated_logger.rb
|
108
109
|
- lib/liveqa/group.rb
|
109
110
|
- lib/liveqa/identity.rb
|
110
111
|
- lib/liveqa/library_name.rb
|
@@ -118,6 +119,9 @@ files:
|
|
118
119
|
- lib/liveqa/plugins/sidekiq/client_middleware.rb
|
119
120
|
- lib/liveqa/plugins/sidekiq/load.rb
|
120
121
|
- lib/liveqa/plugins/sidekiq/server_middleware.rb
|
122
|
+
- lib/liveqa/processor/async.rb
|
123
|
+
- lib/liveqa/processor/batch.rb
|
124
|
+
- lib/liveqa/processor/worker.rb
|
121
125
|
- lib/liveqa/request.rb
|
122
126
|
- lib/liveqa/store.rb
|
123
127
|
- lib/liveqa/util.rb
|
@@ -125,10 +129,10 @@ files:
|
|
125
129
|
- lib/liveqa/watcher.rb
|
126
130
|
- liveqa.gemspec
|
127
131
|
- spec/lib/liveqa/api_resource_spec.rb
|
128
|
-
- spec/lib/liveqa/
|
129
|
-
- spec/lib/liveqa/async_handlers/sidekiq_spec.rb
|
132
|
+
- spec/lib/liveqa/batch_spec.rb
|
130
133
|
- spec/lib/liveqa/config_spec.rb
|
131
134
|
- spec/lib/liveqa/event_spec.rb
|
135
|
+
- spec/lib/liveqa/formated_logger_spec.rb
|
132
136
|
- spec/lib/liveqa/group_spec.rb
|
133
137
|
- spec/lib/liveqa/identity_spec.rb
|
134
138
|
- spec/lib/liveqa/liveqa_object_spec.rb
|
@@ -138,6 +142,9 @@ files:
|
|
138
142
|
- spec/lib/liveqa/plugins/rails/middleware_data_spec.rb
|
139
143
|
- spec/lib/liveqa/plugins/sidekiq/client_middleware_spec.rb
|
140
144
|
- spec/lib/liveqa/plugins/sidekiq/server_middleware_spec.rb
|
145
|
+
- spec/lib/liveqa/processor/async_spec.rb
|
146
|
+
- spec/lib/liveqa/processor/batch_spec.rb
|
147
|
+
- spec/lib/liveqa/processor/worker_spec.rb
|
141
148
|
- spec/lib/liveqa/store_spec.rb
|
142
149
|
- spec/lib/liveqa/util_spec.rb
|
143
150
|
- spec/lib/liveqa/watcher_spec.rb
|
@@ -170,10 +177,10 @@ specification_version: 4
|
|
170
177
|
summary: LiveQA ruby integration
|
171
178
|
test_files:
|
172
179
|
- spec/lib/liveqa/api_resource_spec.rb
|
173
|
-
- spec/lib/liveqa/
|
174
|
-
- spec/lib/liveqa/async_handlers/sidekiq_spec.rb
|
180
|
+
- spec/lib/liveqa/batch_spec.rb
|
175
181
|
- spec/lib/liveqa/config_spec.rb
|
176
182
|
- spec/lib/liveqa/event_spec.rb
|
183
|
+
- spec/lib/liveqa/formated_logger_spec.rb
|
177
184
|
- spec/lib/liveqa/group_spec.rb
|
178
185
|
- spec/lib/liveqa/identity_spec.rb
|
179
186
|
- spec/lib/liveqa/liveqa_object_spec.rb
|
@@ -183,6 +190,9 @@ test_files:
|
|
183
190
|
- spec/lib/liveqa/plugins/rails/middleware_data_spec.rb
|
184
191
|
- spec/lib/liveqa/plugins/sidekiq/client_middleware_spec.rb
|
185
192
|
- spec/lib/liveqa/plugins/sidekiq/server_middleware_spec.rb
|
193
|
+
- spec/lib/liveqa/processor/async_spec.rb
|
194
|
+
- spec/lib/liveqa/processor/batch_spec.rb
|
195
|
+
- spec/lib/liveqa/processor/worker_spec.rb
|
186
196
|
- spec/lib/liveqa/store_spec.rb
|
187
197
|
- spec/lib/liveqa/util_spec.rb
|
188
198
|
- spec/lib/liveqa/watcher_spec.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module LiveQA
|
2
|
-
module AsyncHandlers
|
3
|
-
class Base
|
4
|
-
|
5
|
-
def enqueue(*)
|
6
|
-
raise LiveQA::MissingImplementation, 'Method \'enqueue\' need to be implemented in a subclass'
|
7
|
-
end
|
8
|
-
|
9
|
-
def execute(args)
|
10
|
-
Object.const_get(args[0]).send(args[1].to_sym, *args[2..-1])
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'sidekiq'
|
2
|
-
|
3
|
-
module LiveQA
|
4
|
-
module AsyncHandlers
|
5
|
-
class Sidekiq < Base
|
6
|
-
include ::Sidekiq::Worker
|
7
|
-
|
8
|
-
OPTIONS = {
|
9
|
-
'queue' => 'liveqa',
|
10
|
-
'class' => self
|
11
|
-
}.freeze
|
12
|
-
|
13
|
-
attr_reader :options
|
14
|
-
|
15
|
-
def initialize(options = {})
|
16
|
-
@options = OPTIONS.merge(
|
17
|
-
Util.deep_stringify_key(options)
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
def enqueue(*args)
|
22
|
-
::Sidekiq::Client.push(
|
23
|
-
options.merge('args' => args)
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
def perform(*args)
|
28
|
-
execute(args)
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe LiveQA::AsyncHandlers::Base do
|
4
|
-
subject(:base) { LiveQA::AsyncHandlers::Base.new }
|
5
|
-
|
6
|
-
describe '#enqueue' do
|
7
|
-
subject(:enqueue) { base.enqueue('Event', 'create', test: true) }
|
8
|
-
|
9
|
-
it { expect { enqueue }.to raise_error(LiveQA::MissingImplementation) }
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'execute' do
|
13
|
-
context 'default params' do
|
14
|
-
let(:params) { ['LiveQA::Event', 'create', { test: true }] }
|
15
|
-
|
16
|
-
after { base.execute(params) }
|
17
|
-
|
18
|
-
it { expect(LiveQA::Event).to receive(:create).with({ test: true }) }
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'more params params' do
|
22
|
-
let(:params) { ['LiveQA::Group', 'update', 42, { test: true }, { no_ssl: true }] }
|
23
|
-
|
24
|
-
after { base.execute(params) }
|
25
|
-
|
26
|
-
it { expect(LiveQA::Group).to receive(:update).with(42, { test: true }, { no_ssl: true }) }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'liveqa/async_handlers/sidekiq'
|
3
|
-
|
4
|
-
describe LiveQA::AsyncHandlers::Sidekiq do
|
5
|
-
let(:params) {{}}
|
6
|
-
subject(:sidekiq) { LiveQA::AsyncHandlers::Sidekiq.new(params) }
|
7
|
-
|
8
|
-
describe '#initialize' do
|
9
|
-
it { expect(sidekiq.options['queue']).to eq('liveqa') }
|
10
|
-
it { expect(sidekiq.options['class']).to eq(LiveQA::AsyncHandlers::Sidekiq) }
|
11
|
-
|
12
|
-
context 'with options' do
|
13
|
-
let(:params) {{
|
14
|
-
queue: 'default'
|
15
|
-
}}
|
16
|
-
|
17
|
-
it { expect(sidekiq.options['queue']).to eq('default') }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#enqueue' do
|
22
|
-
after { sidekiq.enqueue('Event', 'create', test: true) }
|
23
|
-
|
24
|
-
let(:expected_params) {{
|
25
|
-
'queue' => 'liveqa',
|
26
|
-
'class' => LiveQA::AsyncHandlers::Sidekiq,
|
27
|
-
'args' => ['Event', 'create', { test: true }]
|
28
|
-
}}
|
29
|
-
|
30
|
-
it { expect(::Sidekiq::Client).to receive(:push).with(expected_params) }
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'perform' do
|
34
|
-
let(:expected_params) { ['LiveQA::Event', 'create', { test: true }] }
|
35
|
-
|
36
|
-
after { sidekiq.perform(*expected_params) }
|
37
|
-
|
38
|
-
it { expect(sidekiq).to receive(:execute).with(expected_params) }
|
39
|
-
end
|
40
|
-
end
|