test/test_helper.rb in searchkick-0.8.5 vs test/test_helper.rb in searchkick-0.8.6
- old
+ new
@@ -71,10 +71,49 @@
class Dog < Animal
end
class Cat < Animal
end
+elsif defined?(NoBrainer)
+ NoBrainer.configure do |config|
+ config.app_name = :searchkick
+ config.environment = :test
+ end
+
+ class Product
+ include NoBrainer::Document
+ include NoBrainer::Document::Timestamps
+
+ field :name, type: String
+ 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, type: String
+ field :latitude
+ field :longitude
+ field :description, type: String
+ end
+
+ class Store
+ include NoBrainer::Document
+
+ field :name, type: String
+ end
+
+ class Animal
+ include NoBrainer::Document
+
+ field :name, type: String
+ end
+
+ class Dog < Animal
+ end
+
+ class Cat < Animal
+ end
else
require "active_record"
# for debugging
# ActiveRecord::Base.logger = Logger.new(STDOUT)
@@ -84,10 +123,12 @@
ActiveRecord::Base.time_zone_aware_attributes = true
# migrations
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
+ ActiveRecord::Base.raise_in_transactional_callbacks = true if ActiveRecord::Base.respond_to?(:raise_in_transactional_callbacks=)
+
ActiveRecord::Migration.create_table :products do |t|
t.string :name
t.integer :store_id
t.boolean :in_stock
t.boolean :backordered
@@ -95,10 +136,10 @@
t.integer :price
t.string :color
t.decimal :latitude, precision: 10, scale: 7
t.decimal :longitude, precision: 10, scale: 7
t.text :description
- t.timestamps
+ t.timestamps null: true
end
ActiveRecord::Migration.create_table :stores do |t|
t.string :name
end