Sha256: 952ce6fa561b845d03446f2c894d06eba87cd070ad9901a88e8928283a1d4e39

Contents?: true

Size: 1.19 KB

Versions: 11

Compression:

Stored size: 1.19 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
    searchable do
      text :title
    end
  end

  class Bar
    include Mongoid::Document
    field :title

    include Sunspot::Mongoid
    searchable(: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.searchable' do
      mock(Sunspot).setup(Foo)
      Foo.searchable
    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

11 entries across 11 versions & 4 rubygems

Version Path
sunspot_mongoid2-0.5.1.5 test/test_sunspot_mongoid.rb
sunspot_mongoid-0.4.1 test/test_sunspot_mongoid.rb
aq1018-sunspot_mongoid-0.5.0 test/test_sunspot_mongoid.rb
aq1018-sunspot_mongoid-0.4.0 test/test_sunspot_mongoid.rb
vinova_sunspot_mongoid-0.3.5 test/test_sunspot_mongoid.rb
sunspot_mongoid-0.4.0 test/test_sunspot_mongoid.rb
vinova_sunspot_mongoid-0.3.4 test/test_sunspot_mongoid.rb
sunspot_mongoid-0.3.2 test/test_sunspot_mongoid.rb
sunspot_mongoid-0.3.1 test/test_sunspot_mongoid.rb
sunspot_mongoid-0.3.0 test/test_sunspot_mongoid.rb
sunspot_mongoid-0.2.0 test/test_sunspot_mongoid.rb