test/test_helper.rb in searchkick-0.8.7 vs test/test_helper.rb in searchkick-0.9.0
- old
+ new
@@ -6,13 +6,15 @@
ENV["RACK_ENV"] = "test"
Minitest::Test = Minitest::Unit::TestCase unless defined?(Minitest::Test)
-File.delete("elasticsearch.log") if File.exists?("elasticsearch.log")
+File.delete("elasticsearch.log") if File.exist?("elasticsearch.log")
Searchkick.client.transport.logger = Logger.new("elasticsearch.log")
+puts "Running against Elasticsearch #{Searchkick.server_version}"
+
I18n.config.enforce_available_locales = true
ActiveJob::Base.logger = nil if defined?(ActiveJob)
if defined?(Mongoid)
@@ -24,11 +26,11 @@
if mongoid2?
# enable comparison of BSON::ObjectIds
module BSON
class ObjectId
def <=>(other)
- self.data <=> other.data
+ data <=> other.data
end
end
end
end
@@ -208,24 +210,27 @@
name != "DO NOT INDEX"
end
end
class Store
- searchkick mappings: {
- store: {
- properties: {
- name: {type: "string", analyzer: "keyword"}
+ searchkick \
+ routing: :name,
+ merge_mappings: true,
+ mappings: {
+ store: {
+ properties: {
+ name: {type: "string", analyzer: "keyword"},
+ }
}
- }
}
end
class Animal
searchkick \
autocomplete: [:name],
suggest: [:name],
- index_name: -> { "#{self.name.tableize}-#{Date.today.year}" }
+ index_name: -> { "#{name.tableize}-#{Date.today.year}" }
# wordnet: true
end
Product.searchkick_index.delete if Product.searchkick_index.exists?
Product.reindex
@@ -250,10 +255,10 @@
end
klass.searchkick_index.refresh
end
def store_names(names, klass = Product)
- store names.map{|name| {name: name} }, klass
+ store names.map { |name| {name: name} }, klass
end
# no order
def assert_search(term, expected, options = {}, klass = Product)
assert_equal expected.sort, klass.search(term, options).map(&:name).sort