test/test_helper.rb in searchkick-2.1.1 vs test/test_helper.rb in searchkick-2.2.0
- old
+ new
@@ -43,10 +43,14 @@
def nobrainer?
defined?(NoBrainer)
end
+def cequel?
+ defined?(Cequel)
+end
+
if defined?(Mongoid)
Mongoid.logger.level = Logger::INFO
Mongo::Logger.logger.level = Logger::INFO if defined?(Mongo::Logger)
Mongoid.configure do |config|
@@ -160,9 +164,91 @@
class Dog < Animal
end
class Cat < Animal
end
+elsif defined?(Cequel)
+ cequel =
+ Cequel.connect(
+ host: "127.0.0.1",
+ port: 9042,
+ keyspace: "searchkick_test",
+ default_consistency: :all
+ )
+ # cequel.logger = ActiveSupport::Logger.new(STDOUT)
+ cequel.schema.drop! if cequel.schema.exists?
+ cequel.schema.create!
+ Cequel::Record.connection = cequel
+
+ class Product
+ include Cequel::Record
+
+ key :id, :uuid, auto: true
+ column :name, :text, index: true
+ column :store_id, :int
+ column :in_stock, :boolean
+ column :backordered, :boolean
+ column :orders_count, :int
+ column :found_rate, :decimal
+ column :price, :int
+ column :color, :text
+ column :latitude, :decimal
+ column :longitude, :decimal
+ column :description, :text
+ column :alt_description, :text
+ column :created_at, :timestamp
+ end
+
+ class Store
+ include Cequel::Record
+
+ key :id, :timeuuid, auto: true
+ column :name, :text
+
+ # has issue with id serialization
+ def search_data
+ {
+ name: name
+ }
+ end
+ end
+
+ class Region
+ include Cequel::Record
+
+ key :id, :timeuuid, auto: true
+ column :name, :text
+ column :text, :text
+ end
+
+ class Speaker
+ include Cequel::Record
+
+ key :id, :timeuuid, auto: true
+ column :name, :text
+ end
+
+ class Animal
+ include Cequel::Record
+
+ key :id, :timeuuid, auto: true
+ column :name, :text
+
+ # has issue with id serialization
+ def search_data
+ {
+ name: name
+ }
+ end
+ end
+
+ class Dog < Animal
+ end
+
+ class Cat < Animal
+ end
+
+ [Product, Store, Region, Speaker, Animal].each(&:synchronize_schema)
else
require "active_record"
# for debugging
# ActiveRecord::Base.logger = Logger.new(STDOUT)