Sha256: 51337479c60cfb6090268f849968fbeecf6bca011dcf63335ecdecdf69e7ae89

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require 'helper'

#
# NOTE: I think tests are too few...
#
class TestSunspotMongoid < Test::Unit::TestCase
  class Foo
    include Mongoid::Document
    field :title

    include Sunspot::Mongoid
    sunspot_setup do
      text :title
    end
  end

  class Bar
    include Mongoid::Document
    field :title

    include Sunspot::Mongoid
    sunspot_setup(:auto_index => false, :auto_remove => false) do
      text :title
    end
  end

  context 'default' do
    should 'sunspot_options is specified' do
      assert Foo.sunspot_options == {:include => []}
      assert Bar.sunspot_options == {:auto_index=>false, :auto_remove=>false, :include=>[]}
    end

    should 'be called Sunspot.setup when call Foo.sunspot_setup' do
      mock(Sunspot).setup(Foo)
      Foo.sunspot_setup
    end

    should 'get as text_fields from Sunspot::Setup' do
      text_field = Sunspot::Setup.for(Foo).all_text_fields.first
      assert text_field.type == Sunspot::Type::TextType.instance
      assert text_field.name == :title
    end

    should 'search' do
      options = {}
      mock.proxy(Foo).solr_execute_search(options)
      mock(Sunspot).new_search(Foo) { mock(Object.new).execute }
      Foo.search(options)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sunspot_mongoid-0.1.2 test/test_sunspot_mongoid.rb
sunspot_mongoid-0.1.1 test/test_sunspot_mongoid.rb