File tree 2 files changed +20
-5
lines changed
2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -409,7 +409,7 @@ def update_document(options={})
409
409
type : document_type ,
410
410
id : self . id ,
411
411
body : { doc : attributes } } . merge ( options )
412
- )
412
+ ) unless attributes . empty?
413
413
else
414
414
index_document ( options )
415
415
end
Original file line number Diff line number Diff line change @@ -423,10 +423,10 @@ def changes
423
423
context 'when changes are present' do
424
424
425
425
before do
426
- expect ( instance ) . to receive ( :client ) . and_return ( client )
427
- expect ( instance ) . to receive ( :index_name ) . and_return ( 'foo' )
428
- expect ( instance ) . to receive ( :document_type ) . and_return ( 'bar' )
429
- expect ( instance ) . to receive ( :id ) . and_return ( '1' )
426
+ allow ( instance ) . to receive ( :client ) . and_return ( client )
427
+ allow ( instance ) . to receive ( :index_name ) . and_return ( 'foo' )
428
+ allow ( instance ) . to receive ( :document_type ) . and_return ( 'bar' )
429
+ allow ( instance ) . to receive ( :id ) . and_return ( '1' )
430
430
end
431
431
432
432
context 'when the changes are included in the as_indexed_json representation' do
@@ -457,6 +457,21 @@ def changes
457
457
end
458
458
end
459
459
460
+ context 'when none of the changes are included in the as_indexed_json representation' do
461
+
462
+ let ( :instance ) do
463
+ DummyIndexingModelWithCallbacksAndCustomAsIndexedJson . new
464
+ end
465
+
466
+ before do
467
+ instance . instance_variable_set ( :@__changed_model_attributes , { 'bar' => 'D' } )
468
+ end
469
+
470
+ it 'does not update the document' do
471
+ expect ( instance . update_document ) . to_not be ( true )
472
+ end
473
+ end
474
+
460
475
context 'when there are partial updates' do
461
476
462
477
let ( :instance ) do
You can’t perform that action at this time.
0 commit comments