Sha256: 285eaf63637077396a690c82099f7865946d8fd6775e879acbeb6752bf8ecbb3

Contents?: true

Size: 1.55 KB

Versions: 19

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

describe Blacklight::Document::CacheKey do
  let(:attributes) { {} }
  let(:subject) { SolrDocument.new(attributes) }
  it 'SolrDocument includes the module' do
    expect(subject.class).to include(Blacklight::Document::CacheKey)
  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_: ['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

19 entries across 19 versions & 1 rubygems

Version Path
blacklight-5.19.2 spec/models/blacklight/document/cache_key_spec.rb
blacklight-5.19.1 spec/models/blacklight/document/cache_key_spec.rb
blacklight-5.19.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-5.18.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-5.17.2 spec/models/blacklight/document/cache_key_spec.rb
blacklight-6.0.0.pre5 spec/models/blacklight/document/cache_key_spec.rb
blacklight-5.17.1 spec/models/blacklight/document/cache_key_spec.rb
blacklight-5.17.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-6.0.0.pre4 spec/models/blacklight/document/cache_key_spec.rb
blacklight-5.16.4 spec/models/blacklight/document/cache_key_spec.rb
blacklight-6.0.0.pre3 spec/models/blacklight/document/cache_key_spec.rb
blacklight-5.16.3 spec/models/blacklight/document/cache_key_spec.rb
blacklight-5.16.2 spec/models/blacklight/document/cache_key_spec.rb
blacklight-5.16.1 spec/models/blacklight/document/cache_key_spec.rb
blacklight-6.0.0.pre2 spec/models/blacklight/document/cache_key_spec.rb
blacklight-6.0.0.pre1 spec/models/blacklight/document/cache_key_spec.rb
blacklight-5.16.0 spec/models/blacklight/document/cache_key_spec.rb
blacklight-5.15.0 spec/lib/blacklight/document/cache_key_spec.rb
blacklight-5.14.0 spec/lib/blacklight/document/cache_key_spec.rb