send all code we have so far and full test case code.
--- model: contact.rb
class Contact < ActiveRecord::Base
end
--- migration: 001_create_contacts_table.rb
class CreateContacts < ActiveRecord::Migration
def self.up
create_table :contacts do |t|
t.column :first_name, :string
t.column :last_name, :string
end
end
def self.down
drop_table :contacts
end
end
--- fixture: contacts.yml
renat:
id: 1
first_name: Renat
last_name: Akhmerov
yura:
id: 2
first_name: Yury
last_name: Kotlyarov
--- test: contact_test.rb
require File.dirname(__FILE__) + '/../test_helper'
require 'fileutils'
class ContactTest < Test::Unit::TestCase
fixtures :contacts
def setup
if File.exists?('index')
FileUtils.rm_rf('index')
end
end
def test_new_field
Contact.acts_as_ferret :fields => [ :first_name ]
assert_equal 1, Contact.find_by_contents('first_name:Y*').total_hits
assert_equal 1, Contact.find_by_contents('Y*').total_hits
Contact.aaf_index.close
FileUtils.rm_rf('index')
Contact.acts_as_ferret :fields => [ :first_name, :last_name ]
assert_equal 1, Contact.find_by_contents('last_name:K*').total_hits
# it fails on the following line!! a bug here?
assert_equal 1, Contact.find_by_contents('K*').total_hits
end
end
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk