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 @@ -409,7 +409,7 @@ def update_document(options={})
409409 type : document_type ,
410410 id : self . id ,
411411 body : { doc : attributes } } . merge ( options )
412- )
412+ ) unless attributes . empty?
413413 else
414414 index_document ( options )
415415 end
Original file line number Diff line number Diff line change @@ -423,10 +423,10 @@ def changes
423423 context 'when changes are present' do
424424
425425 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' )
430430 end
431431
432432 context 'when the changes are included in the as_indexed_json representation' do
@@ -457,6 +457,21 @@ def changes
457457 end
458458 end
459459
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+
460475 context 'when there are partial updates' do
461476
462477 let ( :instance ) do
You can’t perform that action at this time.
0 commit comments