Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:Chrononaut/no_fuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
bmaland committed Apr 27, 2009
2 parents efa7127 + 086c6ea commit 7afec72
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/no_fuzz.rb
Expand Up @@ -18,7 +18,7 @@ def self.extended(model)
def fuzzy(*fields)
# put the parameters as instance variable of the model
@@model.instance_variable_set(:@fuzzy_fields, fields)
@@model.instance_variable_set(:@fuzzy_ref_id, "#{@@model}_id".downcase)
@@model.instance_variable_set(:@fuzzy_ref_id, "#{@@model.to_s.demodulize.underscore}_id")
@@model.instance_variable_set(:@fuzzy_trigram_model, "#{@@model}Trigram".constantize)
end

Expand Down
16 changes: 11 additions & 5 deletions test/no_fuzz_test.rb
Expand Up @@ -4,15 +4,21 @@ class NoFuzzTest < ActiveSupport::TestCase

load_schema

class Package < ActiveRecord::Base
class PackageTrigram < ActiveRecord::Base
end

class PackageTrigram < ActiveRecord::Base
class Package < ActiveRecord::Base
include NoFuzz

fuzzy :name
end

def test_schema_has_loaded_correctly
assert_equal [], Package.all
assert_equal [], PackageTrigram.all
def test_populating_and_deleting_trigram_index
Package.create!(:name => "abcdef")
Package.populate_trigram_index
assert_equal 5, PackageTrigram.count
Package.clear_trigram_index
assert_equal 0, PackageTrigram.count
end

end
Binary file modified test/test.sqlite3
Binary file not shown.
2 changes: 1 addition & 1 deletion test/test_helper.rb
Expand Up @@ -29,6 +29,6 @@ def load_schema
end

ActiveRecord::Base.establish_connection(config[db_adapter])
#load(File.dirname(__FILE__) + "/schema.rb")
load(File.dirname(__FILE__) + "/schema.rb")
require File.dirname(__FILE__) + '/../rails/init.rb'
end

0 comments on commit 7afec72

Please sign in to comment.