Search sold edition,rake sunspot:solr:run. NewsBulletin.solr_search,NewsBulletin.solr_reindex. Not working
This commit is contained in:
1 parent
8dd1ab32c1
commit
cb17fe0825
46 files changed
+2597
-263
No files matched your search
+12
@@ -0,0 +1,12 @@
|
||||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
require 'shoulda'
|
||||
require 'rr'
|
||||
|
||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
||||
require 'sunspot_mongoid'
|
||||
|
||||
class Test::Unit::TestCase
|
||||
include RR::Adapters::TestUnit
|
||||
end
|
||||
@@ -0,0 +1,51 @@
|
||||
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
|
||||
Reference in new issue
Block a user