Sha256: e17e070f977cc60d1da47d510f523ca08592012d36911a34eb4355361faed10e

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

require 'acceptance/spec_helper'

describe '64 bit integer support' do
  it "ensures all internal id attributes are big ints if one is" do
    large_index = ThinkingSphinx::ActiveRecord::Index.new(:tweet)
    large_index.definition_block = Proc.new {
      indexes text
    }

    small_index = ThinkingSphinx::ActiveRecord::Index.new(:article)
    small_index.definition_block = Proc.new {
      indexes title
    }

    real_time_index = ThinkingSphinx::RealTime::Index.new(:product)
    real_time_index.definition_block = Proc.new {
      indexes name
    }

    ThinkingSphinx::Configuration::ConsistentIds.new(
      [small_index, large_index, real_time_index]
    ).reconcile

    large_index.sources.first.attributes.detect { |attribute|
      attribute.name == 'sphinx_internal_id'
    }.type.should == :bigint

    small_index.sources.first.attributes.detect { |attribute|
      attribute.name == 'sphinx_internal_id'
    }.type.should == :bigint

    real_time_index.attributes.detect { |attribute|
      attribute.name == 'sphinx_internal_id'
    }.type.should == :bigint
  end
end

describe '64 bit document ids', :live => true do
  context 'with ActiveRecord' do
    it 'handles large 32 bit integers with an offset multiplier' do
      user = User.create! :name => 'Pat'
      user.update_column :id, 980190962

      index

      expect(User.search('pat').to_a).to eq([user])
    end
  end

  context 'with Real-Time' do
    it 'handles large 32 bit integers with an offset multiplier' do
      product = Product.create! :name => "Widget"
      product.update_attributes :id => 980190962
      expect(
        Product.search('widget', :indices => ['product_core']).to_a
      ).to eq([product])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thinking-sphinx-3.2.0 spec/acceptance/big_integers_spec.rb
thinking-sphinx-3.1.4 spec/acceptance/big_integers_spec.rb