Sha256: 2c5246135405c682ddf0a4689151b6e1432d9eb4323df3f4f91ec548d35594ff

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe WmsController, type: :controller do
  let(:wms_layer) { instance_double('Geoblacklight::WmsLayer') }
  let(:feature_info) { { values: ['fid', 'layer:example'] } }
  let(:params) do
    { format: 'json', 'URL' => 'http://www.example.com/', 'LAYERS' => 'layer:example',
      'BBOX' => '-74, 40, -68, 43', 'WIDTH' => '500', 'HEIGHT' => '400',
      'QUERY_LAYERS' => 'layer:example', 'X' => '277', 'Y' => '195' }
  end

  before do
    allow(Geoblacklight::WmsLayer).to receive(:new).and_return(wms_layer)
    allow(wms_layer).to receive(:feature_info).and_return(feature_info)
  end

  describe '#handle' do
    it 'returns feature info as json' do
      get :handle, params: params
      expect(response.body).to eq(feature_info.to_json)
    end
  end

  describe '#wms_params' do
    let(:wms_params) { controller.instance_eval { wms_params } }

    it 'returns only permitted params' do
      get :handle, params: params
      expect(wms_params.to_h).not_to eq(params)
      params.delete(:format)
      expect(wms_params.to_h).to eq(params)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geoblacklight-2.4.0 spec/controllers/wms_controller_spec.rb
geoblacklight-2.3.0 spec/controllers/wms_controller_spec.rb