Sha256: 7c4bc25e4d4cf843a6e9d61609131f4f22a3c8a986686e414a97e0c5576636c6

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

require "spec_helper"

describe Spotlight::SolrDocument::SpotlightImages do
  let(:subject) {
    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/'],
    )
  }
  it 'should be a Versions class' do
    expect(subject.spotlight_image_versions).to be_a Spotlight::SolrDocument::SpotlightImages::Versions
  end
  it 'should map 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 'should include 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 'should include 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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-spotlight-0.4.1 spec/models/spotlight/solr_document_images_spec.rb
blacklight-spotlight-0.3.1 spec/models/spotlight/solr_document_images_spec.rb
blacklight-spotlight-0.3.0 spec/models/spotlight/solr_document_images_spec.rb