Sha256: 38f91a76d4600251b16fde1d1e6b9d1795dff00c6aedc4a7877dca25ce17f7ec

Contents?: true

Size: 1.54 KB

Versions: 20

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

describe Geoblacklight::SolrDocument::Carto do
  let(:document) { MyDocument.new }
  let(:geojson_download) { instance_double(Geoblacklight::GeojsonDownload) }

  before do
    class MyDocument
      extend Blacklight::Solr::Document
      include Geoblacklight::SolrDocument::Carto
    end

    allow(Geoblacklight::GeojsonDownload).to receive(:new).and_return(geojson_download)
  end

  describe '#carto_reference' do
    it 'returns nil for restricted documents' do
      expect(document).to receive(:public?).and_return(false)
      expect(document.carto_reference).to be_nil
    end
    it 'returns nil for no download_types' do
      expect(document).to receive(:public?).and_return(true)
      expect(document).to receive(:download_types).and_return(nil)
      expect(document.carto_reference).to be_nil
    end
    it 'returns nil with no :geojson download type' do
      expect(document).to receive(:public?).and_return(true)
      expect(document).to receive(:download_types).and_return(geotiff: 'geotiff')
      expect(document.carto_reference).to be_nil
    end
    it 'Creates and returns a GeojsonDownload url' do
      expect(document).to receive(:public?).and_return(true)
      expect(document).to receive(:download_types)
        .and_return(geojson: { 'stuff' => 'stuff' })
      expect(geojson_download)
        .to receive(:url_with_params)
        .and_return('http://www.example.com/geojsonDownload')
      expect(document.carto_reference).to eq 'http://www.example.com/geojsonDownload'
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
geoblacklight-3.8.1 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-3.8.0 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-4.0.0 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-4.0.0.pre.rc3 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-3.7.0 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-4.0.0.pre.rc2 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-4.0.0.pre.rc1 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-3.6.0 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-3.5.0 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-4.0.0.pre.alpha.3 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-4.0.0.pre.alpha.2 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-4.0.0.pre.alpha.1 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-4.0.0.pre.alpha spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-3.4.0 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-3.3.1 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-3.3.0 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-3.2.0 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-3.1.0 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-3.0.1 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb
geoblacklight-3.0.0 spec/models/concerns/geoblacklight/solr_document/carto_spec.rb