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 @@ -426,7 +426,7 @@ def update_document(options={})
426
426
type : document_type ,
427
427
id : self . id ,
428
428
body : { doc : attributes } } . merge ( options )
429
- )
429
+ ) unless attributes . empty?
430
430
else
431
431
index_document ( options )
432
432
end
Original file line number Diff line number Diff line change @@ -440,10 +440,10 @@ def changes
440
440
context 'when changes are present' do
441
441
442
442
before do
443
- expect ( instance ) . to receive ( :client ) . and_return ( client )
444
- expect ( instance ) . to receive ( :index_name ) . and_return ( 'foo' )
445
- expect ( instance ) . to receive ( :document_type ) . and_return ( 'bar' )
446
- expect ( instance ) . to receive ( :id ) . and_return ( '1' )
443
+ allow ( instance ) . to receive ( :client ) . and_return ( client )
444
+ allow ( instance ) . to receive ( :index_name ) . and_return ( 'foo' )
445
+ allow ( instance ) . to receive ( :document_type ) . and_return ( 'bar' )
446
+ allow ( instance ) . to receive ( :id ) . and_return ( '1' )
447
447
end
448
448
449
449
context 'when the changes are included in the as_indexed_json representation' do
@@ -474,6 +474,21 @@ def changes
474
474
end
475
475
end
476
476
477
+ context 'when none of the changes are included in the as_indexed_json representation' do
478
+
479
+ let ( :instance ) do
480
+ DummyIndexingModelWithCallbacksAndCustomAsIndexedJson . new
481
+ end
482
+
483
+ before do
484
+ instance . instance_variable_set ( :@__changed_model_attributes , { 'bar' => 'D' } )
485
+ end
486
+
487
+ it 'does not update the document' do
488
+ expect ( instance . update_document ) . to_not be ( true )
489
+ end
490
+ end
491
+
477
492
context 'when there are partial updates' do
478
493
479
494
let ( :instance ) do
You can’t perform that action at this time.
0 commit comments