Sha256: 34b0839fb58236e39323ef6525fc1e4269f22c8e1df454a8574015eb9919b9fd

Contents?: true

Size: 984 Bytes

Versions: 18

Compression:

Stored size: 984 Bytes

Contents

require 'spec_helper'

describe Spotlight::SolrDocument::AtomicUpdates, type: :model do
  let(:blacklight_solr) { double }
  subject do
    ::SolrDocument.new.extend(described_class)
  end

  before do
    allow(subject).to receive_messages(blacklight_solr: blacklight_solr)
  end

  describe '#reindex' do
    before do
      allow(subject).to receive_messages(to_solr: { id: 'doc_id', a: 1, b: 2 })
    end

    it 'sends an atomic update request' do
      expected = {
        params: { commitWithin: 500 },
        data: [{ id: 'doc_id', a: { set: 1 }, b: { set: 2 } }].to_json,
        headers: { 'Content-Type' => 'application/json' }
      }
      expect(blacklight_solr).to receive(:update).with(expected)
      subject.reindex
    end

    it 'cowardlies refuse to index a document if the only value is an id' do
      allow(subject).to receive_messages(to_solr: { id: 'doc_id' })
      expect(blacklight_solr).not_to receive(:update)
      subject.reindex
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
blacklight-spotlight-0.12.1 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.12.0 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.11.0 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.10.3 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.10.2 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.10.1 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.10.0 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.9.2 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.9.1 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.9.0 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.8.2 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.8.1 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.8.0 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.7.2 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.7.1 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.7.0 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.6.0 spec/models/spotlight/solr_document/atomic_updates_spec.rb
blacklight-spotlight-0.5.0 spec/models/spotlight/solr_document/atomic_updates_spec.rb