Sha256: f0142c06c835b8a3f26c6449ce2ae5ff66662cfadcff4e575808debd3cce3fb8

Contents?: true

Size: 815 Bytes

Versions: 2

Compression:

Stored size: 815 Bytes

Contents

require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
require 'pp'
require 'fileutils'

class FerretResultTest < ActiveSupport::TestCase

  def teardown
  end
  
  def test_get_prefetched_fields_from_hash
    fr = ActsAsFerret::FerretResult.new 'Content', '1', 0.5, 1, :description => 'description from ferret index'
    assert_equal 'description from ferret index', fr.description
    assert_equal 0.5, fr.ferret_score
    assert_equal 1, fr.ferret_rank
    assert_equal 'My Title', fr.title # triggers auto-load of the record
    assert_equal 'A useless description', fr.description # description now comes from DB
  end

  def test_to_param
    fr = ActsAsFerret::FerretResult.new 'Content', '1', 0.5, 1, :description => 'description from ferret index'
    assert_equal '1', fr.to_param
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acts_as_ferret-0.5.4 doc/demo/test/unit/ferret_result_test.rb
acts_as_ferret-0.5.3 doc/demo/test/unit/ferret_result_test.rb