Sha256: ae590655fc524000f89a8adcc584b794aeee0a97020501babefae92792b87e2d

Contents?: true

Size: 804 Bytes

Versions: 7

Compression:

Stored size: 804 Bytes

Contents

require 'spec_helper'

class ActiveModelProductLocalized < StubModelBase
  ac_field :name, :localized => true

  def self.test_data
    [
        {:name_ru => 'name_ru first', :name_en => 'name_en first'},
        {:name_ru => 'name_ru second', :name_en => 'name_en second'}
    ]
  end

  def self.populate
    test_data.each_with_index do |data, id|
      u = new(data)
      u.id = id
      u.save
    end
  end
end

describe 'suggestions for localized attributes' do
  let(:model) { ActiveModelProductLocalized }

  before :all do
    model.setup_index
  end

  it 'don\'t suggest from all locales' do
    model.ac_search('name_en first').to_a.should have(1).results
    model.ac_search('name_ru first').to_a.should have(1).results
    model.ac_search('name_ru').to_a.should have(2).results
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
elasticsearch_autocomplete-0.1.2 spec/elasticsearch_autocomplete/localized_spec.rb
elasticsearch_autocomplete-0.1.1 spec/elasticsearch_autocomplete/localized_spec.rb
elasticsearch_autocomplete-0.1.0 spec/elasticsearch_autocomplete/localized_spec.rb
elasticsearch_autocomplete-0.0.4 spec/elasticsearch_autocomplete/localized_spec.rb
elasticsearch_autocomplete-0.0.3 spec/elasticsearch_autocomplete/localized_spec.rb
elasticsearch_autocomplete-0.0.2 spec/elasticsearch_autocomplete/localized_spec.rb
elasticsearch_autocomplete-0.0.1 spec/elasticsearch_autocomplete/localized_spec.rb