algoliasearch 1.7.0 → 1.8.0

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.
@@ -50,7 +50,7 @@ Gem::Specification.new do |s|
50
50
  s.specification_version = 4
51
51
 
52
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
- s.add_runtime_dependency(%q<httpclient>, ["~> 2.4"])
53
+ s.add_runtime_dependency(%q<httpclient>, ["~> 2.7.1"])
54
54
  s.add_runtime_dependency(%q<json>, [">= 1.5.1"])
55
55
  s.add_development_dependency "travis"
56
56
  s.add_development_dependency "rake"
@@ -336,6 +336,7 @@ module Algolia
336
336
  # @param objectID the unique identifier of object to delete
337
337
  #
338
338
  def delete_object(objectID)
339
+ raise ArgumentError.new('objectID must not be blank') if objectID.nil? || objectID == ''
339
340
  client.delete(Protocol.object_uri(name, objectID))
340
341
  end
341
342
 
@@ -1,3 +1,3 @@
1
1
  module Algolia
2
- VERSION = "1.7.0"
2
+ VERSION = "1.8.0"
3
3
  end
@@ -6,41 +6,41 @@ rescue LoadError
6
6
  end
7
7
 
8
8
  # list indexes
9
- WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/indexes/).to_return(:body => '{ "items": [] }')
9
+ WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes/).to_return(:body => '{ "items": [] }')
10
10
  # query index
11
- WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+/).to_return(:body => '{ "hits": [ { "objectID": 42 } ], "page": 1, "hitsPerPage": 1 }')
11
+ WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+/).to_return(:body => '{ "hits": [ { "objectID": 42 } ], "page": 1, "hitsPerPage": 1 }')
12
12
  # delete index
13
- WebMock.stub_request(:delete, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
13
+ WebMock.stub_request(:delete, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
14
14
  # clear index
15
- WebMock.stub_request(:post, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/clear/).to_return(:body => '{ "taskID": 42 }')
15
+ WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/clear/).to_return(:body => '{ "taskID": 42 }')
16
16
  # add object
17
- WebMock.stub_request(:post, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
17
+ WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
18
18
  # save object
19
- WebMock.stub_request(:put, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
19
+ WebMock.stub_request(:put, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
20
20
  # partial update
21
- WebMock.stub_request(:put, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/[^\/]+\/partial/).to_return(:body => '{ "taskID": 42 }')
21
+ WebMock.stub_request(:put, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/[^\/]+\/partial/).to_return(:body => '{ "taskID": 42 }')
22
22
  # get object
23
- WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/[^\/]+/).to_return(:body => '{}')
23
+ WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/[^\/]+/).to_return(:body => '{}')
24
24
  # delete object
25
- WebMock.stub_request(:delete, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
25
+ WebMock.stub_request(:delete, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
26
26
  # batch
27
- WebMock.stub_request(:post, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/batch/).to_return(:body => '{ "taskID": 42 }')
27
+ WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/batch/).to_return(:body => '{ "taskID": 42 }')
28
28
  # settings
29
- WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/settings/).to_return(:body => '{}')
30
- WebMock.stub_request(:put, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/settings/).to_return(:body => '{ "taskID": 42 }')
29
+ WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/settings/).to_return(:body => '{}')
30
+ WebMock.stub_request(:put, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/settings/).to_return(:body => '{ "taskID": 42 }')
31
31
  # browse
32
- WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/browse/).to_return(:body => '{}')
32
+ WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/browse/).to_return(:body => '{}')
33
33
  # operations
34
- WebMock.stub_request(:post, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/operation/).to_return(:body => '{ "taskID": 42 }')
34
+ WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/operation/).to_return(:body => '{ "taskID": 42 }')
35
35
  # tasks
36
- WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/task\/[^\/]+/).to_return(:body => '{ "status": "published" }')
36
+ WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/task\/[^\/]+/).to_return(:body => '{ "status": "published" }')
37
37
  # index keys
38
- WebMock.stub_request(:post, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/keys/).to_return(:body => '{ }')
39
- WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/keys/).to_return(:body => '{ "keys": [] }')
38
+ WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/keys/).to_return(:body => '{ }')
39
+ WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/keys/).to_return(:body => '{ "keys": [] }')
40
40
  # global keys
41
- WebMock.stub_request(:post, /.*\.algolia\.(io|net)\/1\/keys/).to_return(:body => '{ }')
42
- WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/keys/).to_return(:body => '{ "keys": [] }')
43
- WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/keys\/[^\/]+/).to_return(:body => '{ }')
44
- WebMock.stub_request(:delete, /.*\.algolia\.(io|net)\/1\/keys\/[^\/]+/).to_return(:body => '{ }')
41
+ WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/keys/).to_return(:body => '{ }')
42
+ WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/keys/).to_return(:body => '{ "keys": [] }')
43
+ WebMock.stub_request(:get, /.*\.algolia(net\.com|\.net)\/1\/keys\/[^\/]+/).to_return(:body => '{ }')
44
+ WebMock.stub_request(:delete, /.*\.algolia(net\.com|\.net)\/1\/keys\/[^\/]+/).to_return(:body => '{ }')
45
45
  # query POST
46
- WebMock.stub_request(:post, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/query/).to_return(:body => '{ "hits": [ { "objectID": 42 } ], "page": 1, "hitsPerPage": 1 }')
46
+ WebMock.stub_request(:post, /.*\.algolia(net\.com|\.net)\/1\/indexes\/[^\/]+\/query/).to_return(:body => '{ "hits": [ { "objectID": 42 } ], "page": 1, "hitsPerPage": 1 }')
@@ -196,6 +196,16 @@ describe 'Client' do
196
196
  @index.search('')['nbHits'].should eq(0)
197
197
  end
198
198
 
199
+ it "should not delete the index because the objectID is blank" do
200
+ @index.clear
201
+ @index.add_object!({:firstname => "Robert"})
202
+ res = @index.search('')
203
+ @index.search('')['nbHits'].should eq(1)
204
+ expect { @index.delete_object('') }.to raise_error(ArgumentError)
205
+ expect { @index.delete_object!(nil) }.to raise_error(ArgumentError)
206
+ @index.search('')['nbHits'].should eq(1)
207
+ end
208
+
199
209
  it "should delete several objects" do
200
210
  @index.clear
201
211
  @index.add_object!({:firstname => "Robert1"})
@@ -367,18 +377,18 @@ describe 'Client' do
367
377
  resIndex = @index.list_user_keys
368
378
  newIndexKey = @index.add_user_key(['search'])
369
379
  newIndexKey['key'].should_not eq("")
370
- sleep 2 # no task ID here
380
+ sleep 5 # no task ID here
371
381
  resIndexAfter = @index.list_user_keys
372
382
  is_include(resIndex['keys'], 'value', newIndexKey['key']).should eq(false)
373
383
  is_include(resIndexAfter['keys'], 'value', newIndexKey['key']).should eq(true)
374
384
  indexKey = @index.get_user_key(newIndexKey['key'])
375
385
  indexKey['acl'][0].should eq('search')
376
386
  @index.update_user_key(newIndexKey['key'], ['addObject'])
377
- sleep 2 # no task ID here
387
+ sleep 5 # no task ID here
378
388
  indexKey = @index.get_user_key(newIndexKey['key'])
379
389
  indexKey['acl'][0].should eq('addObject')
380
390
  @index.delete_user_key(newIndexKey['key'])
381
- sleep 2 # no task ID here
391
+ sleep 5 # no task ID here
382
392
  resIndexEnd = @index.list_user_keys
383
393
  is_include(resIndexEnd['keys'], 'value', newIndexKey['key']).should eq(false)
384
394
 
@@ -386,22 +396,20 @@ describe 'Client' do
386
396
  res = Algolia.list_user_keys
387
397
  newKey = Algolia.add_user_key(['search'])
388
398
  newKey['key'].should_not eq("")
389
- sleep 2 # no task ID here
399
+ sleep 5 # no task ID here
390
400
  resAfter = Algolia.list_user_keys
391
401
  is_include(res['keys'], 'value', newKey['key']).should eq(false)
392
402
  is_include(resAfter['keys'], 'value', newKey['key']).should eq(true)
393
403
  key = Algolia.get_user_key(newKey['key'])
394
404
  key['acl'][0].should eq('search')
395
405
  Algolia.update_user_key(newKey['key'], ['addObject'])
396
- sleep 2 # no task ID here
406
+ sleep 5 # no task ID here
397
407
  key = Algolia.get_user_key(newKey['key'])
398
408
  key['acl'][0].should eq('addObject')
399
409
  Algolia.delete_user_key(newKey['key'])
400
- sleep 2 # no task ID here
410
+ sleep 5 # no task ID here
401
411
  resEnd = Algolia.list_user_keys
402
412
  is_include(resEnd['keys'], 'value', newKey['key']).should eq(false)
403
-
404
-
405
413
  end
406
414
 
407
415
  it "should check functions" do
@@ -606,7 +614,7 @@ describe 'Client' do
606
614
  newIndexKey['key'].should be_a(String)
607
615
  newIndexKey.should have_key('createdAt')
608
616
  newIndexKey['createdAt'].should be_a(String)
609
- sleep 2 # no task ID here
617
+ sleep 5 # no task ID here
610
618
  resIndex = @index.list_user_keys
611
619
  resIndex.should have_key('keys')
612
620
  resIndex['keys'].should be_a(Array)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algoliasearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-09 00:00:00.000000000 Z
11
+ date: 2016-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.4'
19
+ version: 2.7.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.4'
26
+ version: 2.7.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  requirements: []
133
133
  rubyforge_project:
134
- rubygems_version: 2.2.2
134
+ rubygems_version: 2.5.1
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: A simple Ruby client for the algolia.com REST API