Sha256: aafe0751088c19c5a9623de4edac6bbb0f3d876892b31f0a2a315568bbfab67c

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

RSpec.describe Blacklight::Gallery::OpenseadragonSolrDocument do
  subject { SolrDocument.new(fields).to_openseadragon(view_config) }

  context 'when configured for the view' do
    let(:fields) { { some_field: 'data' } }
    let(:view_config) { double('ViewConfig', tile_source_field: :some_field) }
    it 'returns the data from the document as an array' do
      expect(subject).to eq ['data']
    end
  end

  context 'when not configured for the view' do
    let(:fields) { { some_field: 'data' } }
    let(:view_config) { double('ViewConfig', tile_source_field: nil) }
    it 'returns nil' do
      expect(subject).to be_nil
    end
  end

  context 'when the document has the field' do
    let(:fields) { { some_field: 'data' } }
    let(:view_config) { double('ViewConfig', tile_source_field: :some_field) }
    it 'returns the data from the document as an array' do
      expect(subject).to eq ['data']
    end
  end

  context 'when the document does not have the field' do
    let(:fields) { { some_other_field: 'data' } }
    let(:view_config) { double('ViewConfig', tile_source_field: :some_field) }
    it 'returns the data from the document as an array' do
      expect(subject).to be_nil
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blacklight-gallery-4.8.4 spec/models/concerns/openseadragon_solr_document_spec.rb
blacklight-gallery-4.8.3 spec/models/concerns/openseadragon_solr_document_spec.rb
blacklight-gallery-4.8.2 spec/models/concerns/openseadragon_solr_document_spec.rb
blacklight-gallery-4.8.1 spec/models/concerns/openseadragon_solr_document_spec.rb
blacklight-gallery-4.8.0 spec/models/concerns/openseadragon_solr_document_spec.rb
blacklight-gallery-4.7.0 spec/models/concerns/openseadragon_solr_document_spec.rb