search_flip 3.0.0.beta2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1198,9 +1198,12 @@ RSpec.describe SearchFlip::Criteria do
1198
1198
 
1199
1199
  query = ProductIndex.criteria.tap(&:records)
1200
1200
 
1201
+ expect(query.instance_variable_get(:@request)).not_to be_nil
1201
1202
  expect(query.instance_variable_get(:@response)).not_to be_nil
1202
1203
 
1203
1204
  expect(query.object_id).not_to eq(query.fresh.object_id)
1205
+
1206
+ expect(query.fresh.instance_variable_get(:@request)).to be_nil
1204
1207
  expect(query.fresh.instance_variable_get(:@response)).to be_nil
1205
1208
  end
1206
1209
  end
@@ -1234,10 +1237,49 @@ RSpec.describe SearchFlip::Criteria do
1234
1237
  end
1235
1238
  end
1236
1239
 
1240
+ describe "#execute" do
1241
+ around do |example|
1242
+ default_instrumenter = SearchFlip::Config[:instrumenter]
1243
+
1244
+ SearchFlip::Config[:instrumenter] = ActiveSupport::Notifications.instrumenter
1245
+
1246
+ begin
1247
+ example.run
1248
+ ensure
1249
+ SearchFlip::Config[:instrumenter] = default_instrumenter
1250
+ end
1251
+ end
1252
+
1253
+ let(:notifications) { [] }
1254
+
1255
+ let!(:subscriber) do
1256
+ ActiveSupport::Notifications.subscribe("request.search_flip") do |*args|
1257
+ notifications << args
1258
+ end
1259
+ end
1260
+
1261
+ after { ActiveSupport::Notifications.unsubscribe(subscriber) }
1262
+
1263
+ it "instruments the request" do
1264
+ ProductIndex.match_all.execute
1265
+
1266
+ expect(notifications).to be_present
1267
+ end
1268
+
1269
+ it "passes the index, request and response" do
1270
+ ProductIndex.match_all.execute
1271
+
1272
+ expect(notifications.first[4][:index]).to eq(ProductIndex)
1273
+ expect(notifications.first[4][:request]).to be_present
1274
+ expect(notifications.first[4][:response]).to be_present
1275
+ end
1276
+ end
1277
+
1237
1278
  describe "#track_total_hits" do
1238
1279
  it "is added to the request" do
1239
1280
  if ProductIndex.connection.version.to_i >= 7
1240
1281
  query = ProductIndex.track_total_hits(false)
1282
+
1241
1283
  expect(query.request[:track_total_hits]).to eq(false)
1242
1284
  expect { query.execute }.not_to raise_error
1243
1285
  end
@@ -0,0 +1,43 @@
1
+ require File.expand_path("../spec_helper", __dir__)
2
+
3
+ RSpec.describe SearchFlip::NullInstrumenter do
4
+ subject { described_class.new }
5
+
6
+ describe "#instrument" do
7
+ it "calls start" do
8
+ allow(subject).to receive(:start)
9
+
10
+ subject.instrument("name", { key: "value" }) {}
11
+
12
+ expect(subject).to have_received(:start)
13
+ end
14
+
15
+ it "calls finish" do
16
+ allow(subject).to receive(:finish)
17
+
18
+ subject.instrument("name", { key: "value" }) {}
19
+
20
+ expect(subject).to have_received(:finish)
21
+ end
22
+
23
+ it "yields and passes the payload" do
24
+ yielded_payload = nil
25
+
26
+ subject.instrument("name", { key: "value" }) { |payload| yielded_payload = payload }
27
+
28
+ expect(yielded_payload).to eq(key: "value")
29
+ end
30
+ end
31
+
32
+ describe "#start" do
33
+ it "returns true" do
34
+ expect(subject.start("name", { key: "value" })).to eq(true)
35
+ end
36
+ end
37
+
38
+ describe "#finish" do
39
+ it "returns true" do
40
+ expect(subject.finish("name", { key: "value" })).to eq(true)
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search_flip
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Vetter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2020-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: ruby2_keywords
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
181
195
  description: Full-Featured Elasticsearch Ruby Client with a Chainable DSL
182
196
  email:
183
197
  - vetter@flakks.com
@@ -202,16 +216,23 @@ files:
202
216
  - lib/search_flip/config.rb
203
217
  - lib/search_flip/connection.rb
204
218
  - lib/search_flip/criteria.rb
219
+ - lib/search_flip/customable.rb
205
220
  - lib/search_flip/exceptions.rb
221
+ - lib/search_flip/explainable.rb
206
222
  - lib/search_flip/filterable.rb
207
223
  - lib/search_flip/helper.rb
224
+ - lib/search_flip/highlightable.rb
208
225
  - lib/search_flip/http_client.rb
209
226
  - lib/search_flip/index.rb
210
227
  - lib/search_flip/json.rb
211
228
  - lib/search_flip/model.rb
229
+ - lib/search_flip/null_instrumenter.rb
230
+ - lib/search_flip/paginatable.rb
212
231
  - lib/search_flip/post_filterable.rb
213
232
  - lib/search_flip/response.rb
214
233
  - lib/search_flip/result.rb
234
+ - lib/search_flip/sortable.rb
235
+ - lib/search_flip/sourceable.rb
215
236
  - lib/search_flip/to_json.rb
216
237
  - lib/search_flip/version.rb
217
238
  - search_flip.gemspec
@@ -223,6 +244,7 @@ files:
223
244
  - spec/search_flip/http_client_spec.rb
224
245
  - spec/search_flip/index_spec.rb
225
246
  - spec/search_flip/model_spec.rb
247
+ - spec/search_flip/null_instrumenter_spec.rb
226
248
  - spec/search_flip/response_spec.rb
227
249
  - spec/search_flip/result_spec.rb
228
250
  - spec/search_flip/to_json_spec.rb
@@ -233,7 +255,7 @@ licenses:
233
255
  metadata: {}
234
256
  post_install_message: |
235
257
  Thanks for using search_flip!
236
- When upgrading from 1.x to 2.x, please check out
258
+ When upgrading to 3.x, please check out
237
259
  https://github.com/mrkamel/search_flip/blob/master/UPDATING.md
238
260
  rdoc_options: []
239
261
  require_paths:
@@ -245,9 +267,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
267
  version: '0'
246
268
  required_rubygems_version: !ruby/object:Gem::Requirement
247
269
  requirements:
248
- - - ">"
270
+ - - ">="
249
271
  - !ruby/object:Gem::Version
250
- version: 1.3.1
272
+ version: '0'
251
273
  requirements: []
252
274
  rubygems_version: 3.0.3
253
275
  signing_key:
@@ -262,6 +284,7 @@ test_files:
262
284
  - spec/search_flip/http_client_spec.rb
263
285
  - spec/search_flip/index_spec.rb
264
286
  - spec/search_flip/model_spec.rb
287
+ - spec/search_flip/null_instrumenter_spec.rb
265
288
  - spec/search_flip/response_spec.rb
266
289
  - spec/search_flip/result_spec.rb
267
290
  - spec/search_flip/to_json_spec.rb