Sha256: 97e81bb60a5e0e82d324ae41c30d7cd27fcdb2eeea89d2908b0f9dfee2138c11

Contents?: true

Size: 1.57 KB

Versions: 70

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

RSpec.describe Blacklight::Document::CacheKey, api: true do
  let(:attributes) { {} }
  let(:subject) { SolrDocument.new(attributes) }

  it 'SolrDocument includes the module' do
    expect(subject.class).to include(described_class)
  end

  describe 'new record' do
    before do
      allow(subject).to receive_messages(new_record?: true)
    end

    it 'provides an acceptable cache key' do
      expect(subject.cache_key).to eq 'solr_documents/new'
    end
  end

  describe 'with version' do
    let(:attributes) { { id: '12345', _version_: '1497353774427013120' } }

    it 'provides a cache key with the id and version' do
      expect(subject.cache_key).to eq 'solr_documents/12345-1497353774427013120'
    end

    describe 'as array' do
      let(:attributes) { { id: '12345', _version_: %w[1234 4321] } }

      it 'provides a cache key with the id and joined version array' do
        expect(subject.cache_key).to eq 'solr_documents/12345-12344321'
      end
    end
  end

  describe 'without version' do
    let(:attributes) { { id: '12345' } }

    it 'provides a cache key with just the id' do
      expect(subject.cache_key).to eq 'solr_documents/12345'
    end
  end

  describe '#cache_version_key' do
    let(:attributes) { { id: '12345', another_version_field: '1497353774427013120' } }

    before do
      allow(subject).to receive_messages(cache_version_key: :another_version_field)
    end

    it 'provides a cache key with the defined field' do
      expect(subject.cache_key).to eq 'solr_documents/12345-1497353774427013120'
    end
  end
end

Version data entries

70 entries across 70 versions & 2 rubygems

Version Path
blacklight-7.40.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-7.39.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-7.38.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/models/blacklight/document/cache_key_spec.rb
blacklight-8.2.2 spec/models/blacklight/document/cache_key_spec.rb
blacklight-8.2.1 spec/models/blacklight/document/cache_key_spec.rb
blacklight-8.2.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-7.37.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-7.36.2 spec/models/blacklight/document/cache_key_spec.rb
blacklight-7.36.1 spec/models/blacklight/document/cache_key_spec.rb
blacklight-7.36.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-7.35.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-8.1.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-7.34.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-8.0.1 spec/models/blacklight/document/cache_key_spec.rb
blacklight-8.0.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-8.0.0.beta8 spec/models/blacklight/document/cache_key_spec.rb
blacklight-8.0.0.beta7 spec/models/blacklight/document/cache_key_spec.rb
blacklight-8.0.0.beta6 spec/models/blacklight/document/cache_key_spec.rb
blacklight-8.0.0.beta5 spec/models/blacklight/document/cache_key_spec.rb