Skip to content

Commit

Permalink
Merge pull request #620 from toptal/avoid-index-updates-with-empty-re…
Browse files Browse the repository at this point in the history
…flections

Avoid Elasticsearch index updates when passing empty reflections
  • Loading branch information
pyromaniac authored Dec 22, 2017
2 parents 1a13f75 + 2eeff14 commit e2a62dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/chewy/type/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def compose(object, crutches = nil, fields: [])
private

def import_routine(*args)
return if args.first.blank? && !args.first.nil?
routine = Routine.new(self, args.extract_options!)
routine.create_indexes!

Expand Down
6 changes: 6 additions & 0 deletions spec/chewy/type/import_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def subscribe_notification
CitiesIndex::City.import(dummy_city)
end

specify 'lazy without objects' do
expect(CitiesIndex).not_to receive(:exists?)
expect(CitiesIndex).not_to receive(:create!)
CitiesIndex::City.import([])
end

context 'skip' do
before do
# To avoid flaky issues when previous specs were run
Expand Down

0 comments on commit e2a62dd

Please sign in to comment.