File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 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={})
426426 type : document_type ,
427427 id : self . id ,
428428 body : { doc : attributes } } . merge ( options )
429- )
429+ ) unless attributes . empty?
430430 else
431431 index_document ( options )
432432 end
Original file line number Diff line number Diff line change @@ -440,10 +440,10 @@ def changes
440440 context 'when changes are present' do
441441
442442 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' )
447447 end
448448
449449 context 'when the changes are included in the as_indexed_json representation' do
@@ -474,6 +474,21 @@ def changes
474474 end
475475 end
476476
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+
477492 context 'when there are partial updates' do
478493
479494 let ( :instance ) do
You can’t perform that action at this time.
0 commit comments