diff --git a/lib/chewy/type/import.rb b/lib/chewy/type/import.rb index 50fdd6f8c..43099dcf9 100644 --- a/lib/chewy/type/import.rb +++ b/lib/chewy/type/import.rb @@ -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! diff --git a/spec/chewy/type/import_spec.rb b/spec/chewy/type/import_spec.rb index 4784fa035..30fe14ba9 100644 --- a/spec/chewy/type/import_spec.rb +++ b/spec/chewy/type/import_spec.rb @@ -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