Sha256: 60f3c02a907388e19da94262d1eab66ef89c5a61490090bdb7fc4ca43b6940d0

Contents?: true

Size: 787 Bytes

Versions: 1

Compression:

Stored size: 787 Bytes

Contents

require 'spec_helper'

describe Mongoid::Fields do
  context 'spatial' do
    before do
      Alarm.create_indexes
    end

    it 'should created indexes' do
      expect(Alarm.collection.indexes.get(spot: '2dsphere')).not_to be_nil
    end

    it 'should create correct indexes' do
      expect(Alarm.collection.indexes.get(spot: '2dsphere'))
        .to include('key' => { 'spot' => '2dsphere' },
                    'name' => 'spot_2dsphere',
                    'ns' => 'mongoid_geo_test.alarms')
    end

    it 'should set spatial fields' do
      expect(Alarm.spatial_fields).to eql([:spot])
    end

    it 'should work fine indexed' do
      far = Alarm.create!(name: 'Far', spot: [7, 7])
      expect(far.spot).to be_instance_of(Mongoid::Geospatial::Point)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-geospatial-5.1.0 spec/mongoid/geospatial/helpers/sphere_spec.rb