-
Notifications
You must be signed in to change notification settings - Fork 13
/
common_spec.rb
42 lines (36 loc) · 1.37 KB
/
common_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'spec_helper'
describe Solrizer::Common do
before do
class Foo
include Solrizer::Common
end
end
after do
Object.send(:remove_const, :Foo)
end
it "should handle many field types" do
solr_doc = {}
Foo.create_and_insert_terms('my_name', 'value', [:displayable, :searchable, :sortable], solr_doc)
solr_doc.should == {'my_name_ssm' => ['value'], 'my_name_si' => 'value', 'my_name_teim' => ['value']}
end
it "should handle dates that are searchable" do
solr_doc = {}
Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:stored_searchable], solr_doc)
solr_doc.should == {'my_name_dtsim' => ['2013-01-10T00:00:00Z']}
end
it "should handle dates that are stored_sortable" do
solr_doc = {}
Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:stored_sortable], solr_doc)
solr_doc.should == {'my_name_dtsi' => '2013-01-10T00:00:00Z'}
end
it "should handle dates that are displayable" do
solr_doc = {}
Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:displayable], solr_doc)
solr_doc.should == {'my_name_ssm' => ['2013-01-10']}
end
it "should handle dates that are sortable" do
solr_doc = {}
Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:sortable], solr_doc)
solr_doc.should == {'my_name_dti' => '2013-01-10T00:00:00Z'}
end
end