Sha256: 2ea7b1fcdc80636e141cf903c562c31f20a434d301ca4764a66f37e19456fe4d

Contents?: true

Size: 1.45 KB

Versions: 11

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

describe Geoblacklight::SpatialSearchBehavior do
  let(:user_params) { Hash.new }
  let(:solr_params) { Hash.new }
  let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
  let(:context) { CatalogController.new }

  let(:search_builder_class) do
    Class.new(Blacklight::SearchBuilder).tap do |klass|
      include Blacklight::Solr::SearchBuilderBehavior
      klass.include(described_class)
    end
  end

  let(:search_builder) { search_builder_class.new(context) }

  subject { search_builder.with(user_params) }

  describe '#add_spatial_params' do
    it 'returns the solr_params when no bbox is given' do
      expect(subject.add_spatial_params(solr_params)).to eq solr_params
    end

    it 'returns a spatial search if bbox is given' do
      params = { bbox: '-180 -80 120 80' }
      subject.with(params)
      expect(subject.add_spatial_params(solr_params)[:fq].to_s).to include('Intersects')
    end
  end
  describe '#envelope_bounds' do
    it 'calls to_envelope on the bounding box' do
      bbox = double('bbox', to_envelope: 'test')
      expect(subject).to receive(:bounding_box).and_return bbox
      expect(subject.envelope_bounds).to eq 'test'
    end
  end
  describe '#bounding_box' do
    it 'creates a bounding box from a Solr lat-lon rectangle format' do
      params = { bbox: '-120 -80 120 80' }
      subject.with(params)
      expect(subject.bounding_box).to be_an Geoblacklight::BoundingBox
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
geoblacklight-1.3.0 spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb
geoblacklight-1.2.0 spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb
geoblacklight-1.1.2 spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb
geoblacklight-1.1.0 spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb
geoblacklight-1.0.3 spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb
geoblacklight-1.0.2 spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb
geoblacklight-1.0.1 spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb
geoblacklight-1.0.0 spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb
geoblacklight-1.0.0.pre3 spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb
geoblacklight-1.0.0.pre2 spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb
geoblacklight-1.0.0.pre1 spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb