test/test_helper.rb in searchkick-0.3.5 vs test/test_helper.rb in searchkick-0.4.1
- old
+ new
@@ -9,26 +9,38 @@
Tire.configure do
logger "elasticsearch.log", :level => "debug"
pretty true
end
-if ENV["MONGOID"]
+if defined?(Mongoid)
Mongoid.configure do |config|
config.connect_to "searchkick_test"
end
class Product
include Mongoid::Document
- # include Mongoid::Attributes::Dynamic
+ include Mongoid::Timestamps
+
+ field :name
+ field :store_id, type: Integer
+ field :in_stock, type: Boolean
+ field :backordered, type: Boolean
+ field :orders_count, type: Integer
+ field :price, type: Integer
+ field :color
+ field :latitude, type: BigDecimal
+ field :longitude, type: BigDecimal
end
class Store
include Mongoid::Document
end
class Animal
include Mongoid::Document
+
+ field :name
end
class Dog < Animal
end
@@ -98,29 +110,29 @@
],
autocomplete: [:name],
suggest: [:name, :color],
conversions: "conversions",
personalize: "user_ids",
- locations: ["location"]
+ locations: ["location", "multiple_locations"]
attr_accessor :conversions, :user_ids
def search_data
- attributes.merge conversions: conversions, user_ids: user_ids, location: [latitude, longitude]
+ serializable_hash.merge conversions: conversions, user_ids: user_ids, location: [latitude, longitude], multiple_locations: [[latitude, longitude], [0, 0]]
end
end
class Animal
- searchkick
+ searchkick autocomplete: [:name], suggest: [:name]
end
Product.searchkick_index.delete if Product.searchkick_index.exists?
Product.reindex
Product.reindex # run twice for both index paths
Animal.reindex
-class MiniTest::Unit::TestCase
+class Minitest::Unit::TestCase
def setup
Product.destroy_all
end