Sha256: 72899903cf27b56491af03b1fbfd32bde4874c39c4507c0cd562deba447a8214

Contents?: true

Size: 1.4 KB

Versions: 20

Compression:

Stored size: 1.4 KB

Contents

require File.join(File.dirname(__FILE__), 'spec_helper')

describe 'indexing dynamic fields' do
  it 'indexes string data' do
    session.index(post(:custom_string => { :test => 'string' }))
    connection.should have_add_with(:"custom_string:test_ss" => 'string')
  end

  it 'indexes integer data with virtual accessor' do
    session.index(post(:category_ids => [1, 2]))
    connection.should have_add_with(:"custom_integer:1_i" => '1', :"custom_integer:2_i" => '1')
  end

  it 'indexes float data' do
    session.index(post(:custom_fl => { :test => 1.5 }))
    connection.should have_add_with(:"custom_float:test_fm" => '1.5')
  end

  it 'indexes time data' do
    session.index(post(:custom_time => { :test => Time.parse('2009-05-18 18:05:00 -0400') }))
    connection.should have_add_with(:"custom_time:test_d" => '2009-05-18T22:05:00Z')
  end

  it 'indexes boolean data' do
    session.index(post(:custom_boolean => { :test => false }))
    connection.should have_add_with(:"custom_boolean:test_b" => 'false')
  end

  it 'indexes multiple values for a field' do
    session.index(post(:custom_fl => { :test => [1.0, 2.1, 3.2] }))
    connection.should have_add_with(:"custom_float:test_fm" => %w(1.0 2.1 3.2))
  end

  it 'should throw a NoMethodError if dynamic text field defined' do
    lambda do
      Sunspot.setup(Post) do
        dynamic_text :custom_text
      end
    end.should raise_error(NoMethodError)
  end
end

Version data entries

20 entries across 20 versions & 5 rubygems

Version Path
erichummel-sunspot-1.2.1g spec/api/indexer/dynamic_fields_spec.rb
erichummel-sunspot-1.2.1f spec/api/indexer/dynamic_fields_spec.rb
erichummel-sunspot-1.2.1b spec/api/indexer/dynamic_fields_spec.rb
erichummel-sunspot-1.2.1a spec/api/indexer/dynamic_fields_spec.rb
lisausa-sunspot-1.2.1.1 spec/api/indexer/dynamic_fields_spec.rb
ruben-sunspot-1.1.4 spec/api/indexer/dynamic_fields_spec.rb
ruben-sunspot-1.1.3 spec/api/indexer/dynamic_fields_spec.rb
ruben-sunspot-1.1.2 spec/api/indexer/dynamic_fields_spec.rb
sunspot-1.2.1 spec/api/indexer/dynamic_fields_spec.rb
sunspot-1.2.0 spec/api/indexer/dynamic_fields_spec.rb
ruben-sunspot-1.1.1 spec/api/indexer/dynamic_fields_spec.rb
ruben-sunspot-1.1.0 spec/api/indexer/dynamic_fields_spec.rb
nuatt_sunspot-1.1.0.3 spec/api/indexer/dynamic_fields_spec.rb
sunspot-1.1.0 spec/api/indexer/dynamic_fields_spec.rb
sunspot-1.0.5 spec/api/indexer/dynamic_fields_spec.rb
sunspot-1.0.4 spec/api/indexer/dynamic_fields_spec.rb
sunspot-1.0.3 spec/api/indexer/dynamic_fields_spec.rb
sunspot-1.0.2 spec/api/indexer/dynamic_fields_spec.rb
sunspot-1.0.1 spec/api/indexer/dynamic_fields_spec.rb
sunspot-1.0.0 spec/api/indexer/dynamic_fields_spec.rb