Sha256: 3b900b4cde29c3949407c229e1ac15885f8ed7628208826d05511cf43bd0cbd4

Contents?: true

Size: 1.74 KB

Versions: 7

Compression:

Stored size: 1.74 KB

Contents

require 'spec_helper'
require 'uri'

describe GeoConcerns::DeliveryJob do
  let(:message) { { 'id' => 'abcdefg', 'event' => 'CREATED', "exchange" => :geoserver } }
  let(:content_url) { 'file:/somewhere-to-display-copy' }
  let(:file_format) { 'application/zip; ogr-format="ESRI Shapefile"' }
  let(:file_set) { instance_double(FileSet, derivative_url: content_url, geo_mime_type: file_format) }

  before do
    allow(ActiveFedora::Base).to receive(:find).and_return(file_set)
  end

  describe '#perform' do
    let(:service) { instance_double('GeoConcerns::DeliveryService') }
    context 'local vector file' do
      it 'delegates to DeliveryService' do
        expect(GeoConcerns::DeliveryService).to receive(:new).with(file_set, URI(content_url).path).and_return(service)
        expect(service).to receive(:publish)
        subject.perform(message)
      end
    end

    context 'local raster file' do
      let(:file_format) { 'image/tiff; gdal-format=GTiff' }
      it 'delegates to DeliveryService' do
        expect(GeoConcerns::DeliveryService).to receive(:new).with(file_set, URI(content_url).path).and_return(service)
        expect(service).to receive(:publish)
        subject.perform(message)
      end
    end

    context 'local image file' do
      let(:file_format) { 'image/jpeg' }
      it 'delegates to DeliveryService' do
        expect(GeoConcerns::DeliveryService).not_to receive(:new)
        subject.perform(message)
      end
    end

    context 'remote file' do
      let(:content_url) { 'http://somewhere/to-display-copy' }
      it 'errors out' do
        expect(GeoConcerns::DeliveryService).not_to receive(:new)
        expect { subject.perform(message) }.to raise_error(NotImplementedError, /Only supports file URLs/)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
geo_concerns-0.3.4 spec/jobs/delivery_job_spec.rb
geo_concerns-0.3.3 spec/jobs/delivery_job_spec.rb
geo_concerns-0.3.2 spec/jobs/delivery_job_spec.rb
geo_concerns-0.3.1 spec/jobs/delivery_job_spec.rb
geo_concerns-0.3.0 spec/jobs/delivery_job_spec.rb
geo_concerns-0.2.0 spec/jobs/delivery_job_spec.rb
geo_concerns-0.1.1 spec/jobs/delivery_job_spec.rb