test/test_helper.rb in searchkick-0.8.0 vs test/test_helper.rb in searchkick-0.8.1
- old
+ new
@@ -8,12 +8,32 @@
File.delete("elasticsearch.log") if File.exists?("elasticsearch.log")
Searchkick.client.transport.logger = Logger.new("elasticsearch.log")
if defined?(Mongoid)
+
+ def mongoid2?
+ Mongoid::VERSION.starts_with?("2.")
+ end
+
+ if mongoid2?
+ # enable comparison of BSON::ObjectIds
+ module BSON
+ class ObjectId
+ def <=>(other)
+ self.data <=> other.data
+ end
+ end
+ end
+ end
+
Mongoid.configure do |config|
- config.connect_to "searchkick_test"
+ if mongoid2?
+ config.master = Mongo::Connection.new.db("searchkick_test")
+ else
+ config.connect_to "searchkick_test"
+ end
end
class Product
include Mongoid::Document
include Mongoid::Timestamps
@@ -119,13 +139,19 @@
text_end: [:name],
word_start: [:name],
word_middle: [:name],
word_end: [:name]
- attr_accessor :conversions, :user_ids
+ attr_accessor :conversions, :user_ids, :aisle
def search_data
- serializable_hash.except("id").merge conversions: conversions, user_ids: user_ids, location: [latitude, longitude], multiple_locations: [[latitude, longitude], [0, 0]]
+ serializable_hash.except("id").merge(
+ conversions: conversions,
+ user_ids: user_ids,
+ location: [latitude, longitude],
+ multiple_locations: [[latitude, longitude], [0, 0]],
+ aisle: aisle
+ )
end
def should_index?
name != "DO NOT INDEX"
end