Skip to content

Commit 88d1d51

Browse files
authored
fix(account-client): retrieve all objects from source index (#399)
* fix(account-client): retrieve all objects from source index * fix(account-client): udpates tests
1 parent b87823b commit 88d1d51

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

lib/algolia/account_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def copy_index(source_index, destination_index, request_options = {})
5555
batch_size = 1000
5656
count = 0
5757

58-
source_index.browse()['hits'].each do |obj|
58+
source_index.browse do |obj|
5959
batch << obj
6060
count += 1
6161

spec/account_client_spec.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@
4747

4848
it 'should perform a cross app copy index and assert that destination must not exist' do
4949

50-
@index_1.save_objects! ([
51-
{:objectID => 'one'},
52-
])
50+
@index_1.save_objects!(1.upto(1500).map { |i| { :objectID => i, :i => i } })
5351

5452
@index_1.batch_rules! ([
5553
{
@@ -67,9 +65,8 @@
6765

6866
Algolia::AccountClient.copy_index!(@index_1, @index_3)
6967

70-
res = @index_3.search('');
71-
res['nbHits'].should eq(1)
72-
res['hits'][0]['objectID'].should eq('one')
68+
res = @index_3.search('')
69+
res['nbHits'].should eq(1500)
7370

7471
res = @index_3.search_rules('')['hits']
7572
res.size.should eq(1)

0 commit comments

Comments
 (0)