test/test_helper.rb in attr_searchable-0.0.3 vs test/test_helper.rb in attr_searchable-0.0.4
- old
+ new
@@ -32,15 +32,16 @@
end
class Product < ActiveRecord::Base
include AttrSearchable
- attr_searchable :title, :description, :brand, :stock, :price, :created_at, :available
- attr_searchable :comment => ["comments.title", "comments.message"], :user => "users.username"
-
+ attr_searchable :title, :description, :brand, :stock, :price, :created_at, :created_on, :available
+ attr_searchable :comment => ["comments.title", "comments.message"], :user => ["users.username", "users_products.username"]
attr_searchable :primary => [:title, :description]
+ attr_searchable_alias :users_products => :user
+
if DATABASE != "sqlite"
attr_searchable_options :title, :type => :fulltext
attr_searchable_options :description, :type => :fulltext
attr_searchable_options :comment, :type => :fulltext
end
@@ -49,10 +50,12 @@
attr_searchable_options :title, :dictionary => "english"
end
has_many :comments
has_many :users, :through => :comments
+
+ belongs_to :user
end
FactoryGirl.define do
factory :product do
end
@@ -67,14 +70,16 @@
ActiveRecord::Base.connection.execute "DROP TABLE IF EXISTS products"
ActiveRecord::Base.connection.execute "DROP TABLE IF EXISTS comments"
ActiveRecord::Base.connection.execute "DROP TABLE IF EXISTS users"
ActiveRecord::Base.connection.create_table :products do |t|
+ t.references :user
t.string :title
t.text :description
t.integer :stock
t.float :price
t.datetime :created_at
+ t.date :created_on
t.boolean :available
t.string :brand
end
ActiveRecord::Base.connection.create_table :comments do |t|