Sha256: 9dd96ca0d93a350d8ffc3bae095a5199b619d10a730a32dbac3499b1c8dc318f

Contents?: true

Size: 1.8 KB

Versions: 23

Compression:

Stored size: 1.8 KB

Contents

describe Spotlight::SolrDocument::SpotlightImages do
  subject do
    SolrDocument.new(
      Spotlight::Engine.config.full_image_field => ['http://lorempixel.com/800/500/'],
      Spotlight::Engine.config.thumbnail_field => ['http://lorempixel.com/400/240/'],
      Spotlight::Engine.config.square_image_field => ['http://lorempixel.com/200/200/']
    )
  end

  it 'is a Versions class' do
    expect(subject.spotlight_image_versions).to be_a Spotlight::SolrDocument::SpotlightImages::Versions
  end
  it 'maps image urls in the document to the appropriate version' do
    expect(subject.spotlight_image_versions.full).to eq ['http://lorempixel.com/800/500/']
    expect(subject.spotlight_image_versions.thumb).to eq ['http://lorempixel.com/400/240/']
    expect(subject.spotlight_image_versions.square).to eq ['http://lorempixel.com/200/200/']
  end
  it 'includes the version keys in the versions array' do
    [:full, :thumb, :square].each do |version|
      expect(subject.spotlight_image_versions.versions).to include version
    end
  end
  it 'includes newly configured image versions' do
    Spotlight::ImageDerivatives.spotlight_image_derivatives << {
      version: :tiny,
      field: :new_image_field
    }
    subject = SolrDocument.new(new_image_field: ['abc'])
    expect(subject.spotlight_image_versions.tiny).to eq ['abc']
    Spotlight::ImageDerivatives.spotlight_image_derivatives.delete_if do |d|
      d[:version] == :tiny
    end
  end

  it 'gracefully handles missing data' do
    subject = SolrDocument.new Spotlight::Engine.config.full_image_field => ['http://lorempixel.com/800/500/']
    expect(subject.spotlight_image_versions.full).to eq ['http://lorempixel.com/800/500/']
    expect(subject.spotlight_image_versions.thumb).to be_empty
    expect(subject.spotlight_image_versions.square).to be_empty
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
blacklight-spotlight-0.32.0 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.31.0 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.30.0 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.29.1 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.29.0 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.28.3 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.28.2 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.28.1 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.28.0 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.27.0 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.26.1 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.26.0 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.25.0 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.24.0 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.23.0 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.22.0 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.21.0 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.20.3 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.20.2 spec/models/spotlight/solr_document/spotlight_images_spec.rb
blacklight-spotlight-0.20.1 spec/models/spotlight/solr_document/spotlight_images_spec.rb