lucid_works 0.7.18 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rvmrc +2 -3
- data/Gemfile +2 -8
- data/Gemfile.lock +45 -53
- data/README.rdoc +2 -6
- data/Rakefile +1 -1
- data/config/locales/en.yml +221 -239
- data/lib/lucid_works/activity.rb +8 -5
- data/lib/lucid_works/base.rb +27 -16
- data/lib/lucid_works/cache.rb +13 -0
- data/lib/lucid_works/cluster.rb +84 -0
- data/lib/lucid_works/collection/settings.rb +15 -6
- data/lib/lucid_works/collection.rb +62 -92
- data/lib/lucid_works/datasource/history.rb +2 -1
- data/lib/lucid_works/datasource/mapping.rb +12 -0
- data/lib/lucid_works/datasource/schedule.rb +5 -2
- data/lib/lucid_works/datasource/status.rb +3 -2
- data/lib/lucid_works/datasource.rb +31 -48
- data/lib/lucid_works/datasource_property.rb +2 -1
- data/lib/lucid_works/datasource_type.rb +14 -0
- data/lib/lucid_works/dynamicfield.rb +12 -0
- data/lib/lucid_works/elevation.rb +93 -0
- data/lib/lucid_works/exceptions.rb +0 -4
- data/lib/lucid_works/field.rb +31 -111
- data/lib/lucid_works/field_commons.rb +133 -0
- data/lib/lucid_works/gem_version.rb +1 -1
- data/lib/lucid_works/inflections.rb +3 -0
- data/lib/lucid_works/patch_time.rb +4 -0
- data/lib/lucid_works/request_handler.rb +16 -0
- data/lib/lucid_works/role.rb +23 -8
- data/lib/lucid_works/schema/attribute.rb +1 -1
- data/lib/lucid_works/schema/boolean_attribute.rb +1 -1
- data/lib/lucid_works/schema/integer_attribute.rb +3 -4
- data/lib/lucid_works/server/crawlers_status.rb +15 -0
- data/lib/lucid_works/server.rb +35 -14
- data/lib/lucid_works/simple_naming.rb +1 -7
- data/lib/lucid_works/synonym.rb +1 -1
- data/lib/lucid_works/version.rb +1 -0
- data/lib/lucid_works.rb +8 -1
- data/lucid_works.gemspec +8 -9
- data/spec/fixtures/zookeeper/clusterstate.json +30 -0
- data/spec/fixtures/zookeeper/clusterstate_broken_shard.json +29 -0
- data/spec/fixtures/zookeeper/live_nodes.json +28 -0
- data/spec/fixtures/zookeeper/live_nodes_no_children.json +26 -0
- data/spec/fixtures/zookeeper/live_nodes_one_child.json +36 -0
- data/spec/lib/lucid_works/base_spec.rb +33 -24
- data/spec/lib/lucid_works/cache_spec.rb +44 -0
- data/spec/lib/lucid_works/cluster_spec.rb +109 -0
- data/spec/lib/lucid_works/collection/activity_spec.rb +29 -0
- data/spec/lib/lucid_works/collection/prime_activities_spec.rb +1 -1
- data/spec/lib/lucid_works/collection/settings_spec.rb +31 -0
- data/spec/lib/lucid_works/collection_spec.rb +166 -107
- data/spec/lib/lucid_works/datasource/schedule_spec.rb +75 -46
- data/spec/lib/lucid_works/datasource/status_spec.rb +5 -5
- data/spec/lib/lucid_works/datasource_property_spec.rb +41 -0
- data/spec/lib/lucid_works/datasource_spec.rb +40 -12
- data/spec/lib/lucid_works/datasource_type_spec.rb +31 -0
- data/spec/lib/lucid_works/dynamicfield_spec.rb +214 -0
- data/spec/lib/lucid_works/elevation_spec.rb +175 -0
- data/spec/lib/lucid_works/field_spec.rb +52 -21
- data/spec/lib/lucid_works/fieldtype_spec.rb +0 -1
- data/spec/lib/lucid_works/request_handler_spec.rb +11 -0
- data/spec/lib/lucid_works/role_spec.rb +77 -0
- data/spec/lib/lucid_works/server/crawlers_status_spec.rb +21 -0
- data/spec/lib/lucid_works/server_spec.rb +123 -22
- data/spec/lib/lucid_works/{collection/synonym_spec.rb → synonym_spec.rb} +23 -22
- data/spec/lib/lucid_works/version_spec.rb +6 -0
- metadata +132 -64
- data/spec/lib/lucid_works/collection/acl_config_spec.rb +0 -212
@@ -11,6 +11,32 @@ describe LucidWorks::Field do
|
|
11
11
|
LucidWorks::Field.new(:parent => @collection).should be_a(LucidWorks::Base)
|
12
12
|
end
|
13
13
|
|
14
|
+
describe "adjusting REST URLs" do
|
15
|
+
context "when include_dynamic is disabled" do
|
16
|
+
it "doesn't change the collection URL" do
|
17
|
+
LucidWorks::Field.collection_url(@collection).should == "http://localhost:8888/api/collections/collection1/fields"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "doesn't change the member URL" do
|
21
|
+
LucidWorks::Field.member_url(@collection, 5).should == "http://localhost:8888/api/collections/collection1/fields/5"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when include_dynamic is enabled" do
|
26
|
+
before do
|
27
|
+
LucidWorks::Field.include_dynamic = true
|
28
|
+
end
|
29
|
+
|
30
|
+
it "changes the collection URL" do
|
31
|
+
LucidWorks::Field.collection_url(@collection).should == "http://localhost:8888/api/collections/collection1/fields?include_dynamic=true"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "changes the member URL" do
|
35
|
+
LucidWorks::Field.member_url(@collection, 5).should == "http://localhost:8888/api/collections/collection1/fields/5?include_dynamic=true"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
14
40
|
describe "default attribute values" do
|
15
41
|
context "for a new field" do
|
16
42
|
subject { LucidWorks::Field.new(:parent => @collection) }
|
@@ -29,7 +55,7 @@ describe LucidWorks::Field do
|
|
29
55
|
LucidWorks::Field.new(
|
30
56
|
:parent => @collection,
|
31
57
|
:indexed => true, :facet => true, :synonym_expansion => true, :omit_tf => true, :short_field_boost => true, :search_by_default => false, :use_in_find_similar => false, :query_time_stopword_handling => false,
|
32
|
-
:stored => true, :include_in_results => true, :highlight => true
|
58
|
+
:stored => true, :include_in_results => true, :highlight => true, :field_type => 'string'
|
33
59
|
)
|
34
60
|
}
|
35
61
|
|
@@ -40,6 +66,7 @@ describe LucidWorks::Field do
|
|
40
66
|
|
41
67
|
it { subject.facet.should be_false }
|
42
68
|
it { subject.synonym_expansion.should be_false }
|
69
|
+
it { subject.omit_positions.should be_false }
|
43
70
|
it { subject.omit_tf.should be_false }
|
44
71
|
it { subject.short_field_boost.should == 'high' }
|
45
72
|
it { subject.search_by_default.should be_false }
|
@@ -62,7 +89,7 @@ describe LucidWorks::Field do
|
|
62
89
|
context "for a new field" do
|
63
90
|
context :name do
|
64
91
|
it "is required" do
|
65
|
-
field = LucidWorks::Field.new(:parent => @collection)
|
92
|
+
field = LucidWorks::Field.new(:field_type => 'string', :parent => @collection)
|
66
93
|
field.should_not be_valid
|
67
94
|
field.errors[:name].should == ["can't be blank"]
|
68
95
|
end
|
@@ -73,54 +100,60 @@ describe LucidWorks::Field do
|
|
73
100
|
field.errors[:name].should == ["must be unique"]
|
74
101
|
end
|
75
102
|
end
|
103
|
+
|
104
|
+
it "requires a field type" do
|
105
|
+
field = LucidWorks::Field.new(:parent => @collection, :name => 'data_source')
|
106
|
+
field.should_not be_valid
|
107
|
+
field.errors[:field_type].should == ["can't be blank"]
|
108
|
+
end
|
76
109
|
|
77
110
|
context :short_field_boost do
|
78
111
|
it "cannot be set to 'none' for a non-indexed field" do
|
79
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => false, :short_field_boost => 'none').tap do |field|
|
112
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string', :indexed => false, :short_field_boost => 'none').tap do |field|
|
80
113
|
field.should_not be_valid
|
81
114
|
field.errors[:short_field_boost].should == ['cannot be set to "none" for a non-indexed field']
|
82
115
|
end
|
83
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true, :short_field_boost => true, :indexing_options => :document_only).should be_valid
|
116
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string', :indexed => true, :short_field_boost => true, :indexing_options => :document_only).should be_valid
|
84
117
|
end
|
85
118
|
end
|
86
119
|
|
87
120
|
context :include_in_results do
|
88
121
|
it "requires the field to be stored" do
|
89
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :stored => false, :include_in_results => true).tap do |field|
|
122
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string', :stored => false, :include_in_results => true).tap do |field|
|
90
123
|
field.should_not be_valid
|
91
124
|
field.errors[:include_in_results].should == ["a field must be stored to be included in results"]
|
92
125
|
end
|
93
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :stored => true, :include_in_results => true, :indexing_options => :document_only).should be_valid
|
126
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string', :stored => true, :include_in_results => true, :indexing_options => :document_only).should be_valid
|
94
127
|
end
|
95
128
|
end
|
96
129
|
|
97
130
|
context :highlight do
|
98
131
|
it "requires the field to be stored" do
|
99
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :stored => false, :highlight => true).tap do |field|
|
132
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string', :stored => false, :highlight => true).tap do |field|
|
100
133
|
field.should_not be_valid
|
101
134
|
field.errors[:highlight].should == ["a field must be stored to be highlighted"]
|
102
135
|
end
|
103
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :stored => true, :highlighted => true).should be_valid
|
136
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string', :stored => true, :highlighted => true).should be_valid
|
104
137
|
end
|
105
138
|
end
|
106
139
|
|
107
140
|
context :facet do
|
108
141
|
it "requires the field to be indexed" do
|
109
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => false, :facet => true).tap do |field|
|
142
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string', :indexed => false, :facet => true).tap do |field|
|
110
143
|
field.should_not be_valid
|
111
144
|
field.errors[:facet].should == ["a field must be indexed to be facetable"]
|
112
145
|
end
|
113
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true, :facet => true, :indexing_options => :document_only).should be_valid
|
146
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string', :indexed => true, :facet => true, :indexing_options => :document_only).should be_valid
|
114
147
|
end
|
115
148
|
end
|
116
149
|
|
117
150
|
context :use_in_find_similar do
|
118
151
|
it "requires the field to be indexed" do
|
119
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => false, :use_in_find_similar => true).tap do |field|
|
152
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string', :indexed => false, :use_in_find_similar => true).tap do |field|
|
120
153
|
field.should_not be_valid
|
121
154
|
field.errors[:use_in_find_similar].should == ["a field must be indexed for it to be used for find-similar"]
|
122
155
|
end
|
123
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true, :use_in_find_similar => true, :indexing_options => :document_only).should be_valid
|
156
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string', :indexed => true, :use_in_find_similar => true, :indexing_options => :document_only).should be_valid
|
124
157
|
end
|
125
158
|
end
|
126
159
|
end
|
@@ -134,7 +167,7 @@ describe LucidWorks::Field do
|
|
134
167
|
end
|
135
168
|
|
136
169
|
describe "indexing options" do
|
137
|
-
|
170
|
+
FIELD_INDEXING_OPTIONS_TRUTH_TABLE = [
|
138
171
|
{ :indexed => true, :indexing_options => :document_termfreq_termpos, :omit_tf => false, :omit_positions => false },
|
139
172
|
{ :indexed => true, :indexing_options => :document_termfreq, :omit_tf => false, :omit_positions => true },
|
140
173
|
{ :indexed => true, :indexing_options => :document_only, :omit_tf => true, :omit_positions => true },
|
@@ -180,11 +213,11 @@ describe LucidWorks::Field do
|
|
180
213
|
describe "getter" do
|
181
214
|
context "when indexed is false" do
|
182
215
|
before do
|
183
|
-
@field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => false)
|
216
|
+
@field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string', :indexed => false)
|
184
217
|
end
|
185
218
|
|
186
219
|
describe "it should always return :document_termfreq_termpos" do
|
187
|
-
|
220
|
+
FIELD_INDEXING_OPTIONS_TRUTH_TABLE.select{ |x| x[:indexed] == 'false'}.each do |settings|
|
188
221
|
it "should return :document_termfreq_termpos if omit_tf=#{settings[:omit_tf]} and omit_positions=#{settings[:omit_positions]}" do
|
189
222
|
settings.each { |k,v| @field.send("#{k}=", v) }
|
190
223
|
@field.indexing_options.should == :document_termfreq_termpos
|
@@ -196,10 +229,10 @@ describe LucidWorks::Field do
|
|
196
229
|
|
197
230
|
context "when indexed is true" do
|
198
231
|
before do
|
199
|
-
@field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true)
|
232
|
+
@field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string', :indexed => true)
|
200
233
|
end
|
201
234
|
|
202
|
-
|
235
|
+
FIELD_INDEXING_OPTIONS_TRUTH_TABLE.select { |x| x[:indexed] == true }.each do |data|
|
203
236
|
it "should return #{data[:indexing_options]} if omit_tf=#{data[:omit_tf]} and omit_positions=#{data[:omit_positions]}" do
|
204
237
|
@field.omit_tf = data[:omit_tf]
|
205
238
|
@field.omit_positions = data[:omit_positions]
|
@@ -207,15 +240,14 @@ describe LucidWorks::Field do
|
|
207
240
|
end
|
208
241
|
end
|
209
242
|
end
|
210
|
-
|
211
243
|
end
|
212
244
|
|
213
245
|
describe "setter" do
|
214
246
|
before do
|
215
|
-
@field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field')
|
247
|
+
@field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :field_type => 'string')
|
216
248
|
end
|
217
249
|
|
218
|
-
|
250
|
+
FIELD_INDEXING_OPTIONS_TRUTH_TABLE.each do |data|
|
219
251
|
|
220
252
|
context "when indexed is set to #{data[:indexed]} BEFORE indexing options is set to #{data[:indexing_options]}" do
|
221
253
|
before do
|
@@ -277,7 +309,6 @@ describe LucidWorks::Field do
|
|
277
309
|
it "should retrieve a field" do
|
278
310
|
field = LucidWorks::Field.find('body', :parent => @collection)
|
279
311
|
field.should be_a(LucidWorks::Field)
|
280
|
-
field.should respond_to(:field_type)
|
281
312
|
end
|
282
313
|
end
|
283
314
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LucidWorks::RequestHandler do
|
4
|
+
let(:server) { connect_to_live_server.tap {|server| server.reset_collections! } }
|
5
|
+
|
6
|
+
subject { server.collections.first.request_handler('lucid') }
|
7
|
+
|
8
|
+
its(:name) { should == 'lucid' }
|
9
|
+
|
10
|
+
its(:default_params) { should include(qf: 'author text_all title^5.0', pf: 'author text_all title^5.0') }
|
11
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LucidWorks::Role do
|
4
|
+
before :all do
|
5
|
+
@server = connect_to_live_server
|
6
|
+
@server.reset_collections!
|
7
|
+
@collection = @server.collection('collection1')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should use the ORM" do
|
11
|
+
LucidWorks::Role.new(:parent => @collection).should be_a(LucidWorks::Base)
|
12
|
+
end
|
13
|
+
|
14
|
+
context "view helper methods" do
|
15
|
+
before do
|
16
|
+
@role = LucidWorks::Role.new(:parent => @collection)
|
17
|
+
end
|
18
|
+
|
19
|
+
context "list is empty" do
|
20
|
+
describe "#users_for_text_field" do
|
21
|
+
it "should return an empty string" do
|
22
|
+
users = []
|
23
|
+
@role.users = users
|
24
|
+
@role.users.should == users
|
25
|
+
@role.users_for_text_field.should == ""
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#groups_for_text_field" do
|
30
|
+
it "should return an empty string" do
|
31
|
+
groups = []
|
32
|
+
@role.groups = groups
|
33
|
+
@role.groups.should == groups
|
34
|
+
@role.groups_for_text_field.should == ""
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#filters_for_text_area" do
|
39
|
+
it "should return an empty string" do
|
40
|
+
filters = []
|
41
|
+
@role.filters = filters
|
42
|
+
@role.filters.should == filters
|
43
|
+
@role.filters_for_text_area.should == ""
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "list is not empty" do
|
49
|
+
describe "#users_for_text_field" do
|
50
|
+
it "should return a comma-space joined string" do
|
51
|
+
users = ["John Smith", "bob"]
|
52
|
+
@role.users = users
|
53
|
+
@role.users.should == users
|
54
|
+
@role.users_for_text_field.should == "John Smith, bob"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#groups_for_text_field" do
|
59
|
+
it "should return a comma-space joined string" do
|
60
|
+
groups = ["Domain Admins", "admins"]
|
61
|
+
@role.groups = groups
|
62
|
+
@role.groups.should == groups
|
63
|
+
@role.groups_for_text_field.should == "Domain Admins, admins"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#filters_for_text_area" do
|
68
|
+
it "should return an empty string" do
|
69
|
+
filters = ["rails", "telecommute*"]
|
70
|
+
@role.filters = filters
|
71
|
+
@role.filters.should == filters
|
72
|
+
@role.filters_for_text_area.should == "rails\ntelecommute*"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LucidWorks::Server::CrawlersStatus do
|
4
|
+
let(:server) { LucidWorks::Server.new('http://1.1.1.1:8888') }
|
5
|
+
|
6
|
+
it "adjusts the member URL" do
|
7
|
+
LucidWorks::Server::CrawlersStatus.member_url(server).should == "http://1.1.1.1:8888/api/crawlers/status"
|
8
|
+
end
|
9
|
+
|
10
|
+
context "with an OK status" do
|
11
|
+
subject { LucidWorks::Server::CrawlersStatus.new(:parent => server, :status => 'OK') }
|
12
|
+
|
13
|
+
it { should be_ok }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "with a non-OK status" do
|
17
|
+
subject { LucidWorks::Server::CrawlersStatus.new(:parent => server, :status => 'WARNING') }
|
18
|
+
|
19
|
+
it { should_not be_ok }
|
20
|
+
end
|
21
|
+
end
|
@@ -1,30 +1,30 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LucidWorks::Server do
|
4
|
-
|
5
|
-
|
4
|
+
describe "exposing attributes" do
|
5
|
+
let(:server_uri) { "http://joe:xyz@fakehost.com:8888" }
|
6
|
+
|
7
|
+
subject { server = LucidWorks::Server.new(server_uri) }
|
8
|
+
|
9
|
+
its(:server_uri) { should == server_uri }
|
10
|
+
its(:uri) { should == server_uri + "/api" } # TODO: 'uri' is a confusing name
|
11
|
+
its(:api_uri) { should == server_uri + "/api" }
|
12
|
+
its(:solr_uri) { should == server_uri + "/solr" }
|
13
|
+
its(:logs_uri) { should == server_uri + "/logs" }
|
14
|
+
its(:host) { should == "fakehost.com" }
|
15
|
+
its(:protocol) { should == "http://" }
|
16
|
+
its(:port) { should == 8888 }
|
17
|
+
its(:user) { should == "joe" }
|
18
|
+
its(:password) { should == "xyz" }
|
6
19
|
end
|
7
20
|
|
8
|
-
describe "
|
9
|
-
|
10
|
-
lambda {
|
11
|
-
LucidWorks::Server.new
|
12
|
-
}.should raise_error(ArgumentError)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should remember the server URL" do
|
16
|
-
server = LucidWorks::Server.new(@fake_server_uri)
|
17
|
-
server.uri.should == @fake_server_uri + "/api"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context "server" do
|
22
|
-
before { @server = LucidWorks::Server.new(@fake_server_uri) }
|
21
|
+
describe "associations" do
|
22
|
+
let(:server) { LucidWorks::Server.new('http://host.example.com:8000') }
|
23
23
|
|
24
24
|
describe "#collection" do
|
25
25
|
it "should call Collection.find and pass the server" do
|
26
|
-
LucidWorks::Collection.should_receive(:find).with('foo', :parent =>
|
27
|
-
|
26
|
+
LucidWorks::Collection.should_receive(:find).with('foo', :parent => server)
|
27
|
+
server.collection('foo')
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -32,11 +32,112 @@ describe LucidWorks::Server do
|
|
32
32
|
it "should create a HasMany association proxy for the specified class" do
|
33
33
|
mock_proxy = double('has_many proxy', :find => nil)
|
34
34
|
LucidWorks::Associations::HasMany.should_receive(:new).
|
35
|
-
with(
|
35
|
+
with(server, LucidWorks::Collection, {}).
|
36
36
|
and_return(mock_proxy)
|
37
|
-
|
38
|
-
|
37
|
+
server.collections
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "helpers" do
|
43
|
+
let(:server) { connect_to_live_server }
|
44
|
+
|
45
|
+
describe "#datasource_types" do
|
46
|
+
before(:each) do
|
47
|
+
RestClient.should_receive(:get).with("#{server.server_uri}/api/crawlers").and_return <<-EOF
|
48
|
+
[
|
49
|
+
{
|
50
|
+
"name" : "lucid.aperture",
|
51
|
+
"datasource_types" : [
|
52
|
+
{
|
53
|
+
"props": [],
|
54
|
+
"type" : "file",
|
55
|
+
"category" : "FileSystem"
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"props": [],
|
59
|
+
"type" : "web",
|
60
|
+
"category" : "Web"
|
61
|
+
}
|
62
|
+
]
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"name" : "lucid.fs",
|
66
|
+
"datasource_types" : [
|
67
|
+
{
|
68
|
+
"props": [],
|
69
|
+
"type" : "file",
|
70
|
+
"category" : "FileSystem"
|
71
|
+
}
|
72
|
+
]
|
73
|
+
}
|
74
|
+
]
|
75
|
+
EOF
|
76
|
+
end
|
77
|
+
|
78
|
+
it "returns a flat list of datasource types" do
|
79
|
+
server.datasource_types.should have(3).items
|
80
|
+
dt = server.datasource_types.first
|
81
|
+
dt.should be_a(LucidWorks::DatasourceType)
|
82
|
+
dt.type.should == "file"
|
83
|
+
dt.crawler.name.should == "lucid.aperture"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "#datasource_type" do
|
88
|
+
before(:each) do
|
89
|
+
RestClient.should_receive(:get).with("#{server.server_uri}/api/crawlers").and_return <<-EOF
|
90
|
+
[
|
91
|
+
{
|
92
|
+
"name" : "lucid.aperture",
|
93
|
+
"datasource_types" : [
|
94
|
+
{
|
95
|
+
"props": [],
|
96
|
+
"type" : "file",
|
97
|
+
"category" : "FileSystem"
|
98
|
+
}
|
99
|
+
]
|
100
|
+
},
|
101
|
+
{
|
102
|
+
"name" : "lucid.fs",
|
103
|
+
"datasource_types" : [
|
104
|
+
{
|
105
|
+
"props": [],
|
106
|
+
"type" : "file",
|
107
|
+
"category" : "FileSystem"
|
108
|
+
}
|
109
|
+
]
|
110
|
+
}
|
111
|
+
]
|
112
|
+
EOF
|
113
|
+
end
|
114
|
+
|
115
|
+
it "finds the datasource type matching the provided type name and crawler name" do
|
116
|
+
dt = server.datasource_type('file', 'lucid.fs')
|
117
|
+
dt.should be_a(LucidWorks::DatasourceType)
|
118
|
+
dt.type.should == "file"
|
119
|
+
dt.crawler.name.should == "lucid.fs"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "#clustered" do
|
125
|
+
subject { LucidWorks::Server.new('http://host.example.com:8000') }
|
126
|
+
|
127
|
+
context "with ZooKeeper" do
|
128
|
+
before(:each) do
|
129
|
+
RestClient.stub(:get).with('http://host.example.com:8000/solr/zookeeper') { '{"some":"json"}' }
|
130
|
+
end
|
131
|
+
|
132
|
+
it { should be_clustered }
|
133
|
+
end
|
134
|
+
|
135
|
+
context "without ZooKeeper" do
|
136
|
+
before(:each) do
|
137
|
+
RestClient.stub(:get).with('http://host.example.com:8000/solr/zookeeper').and_raise RestClient::ResourceNotFound
|
39
138
|
end
|
139
|
+
|
140
|
+
it { should_not be_clustered }
|
40
141
|
end
|
41
142
|
end
|
42
143
|
end
|
@@ -1,27 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LucidWorks::Synonym do
|
4
|
-
|
5
|
-
@server = connect_to_live_server.tap {|server| server.reset_collections! }
|
6
|
-
load_collection
|
7
|
-
end
|
4
|
+
let(:server) { connect_to_live_server.tap {|server| server.reset_collections! } }
|
8
5
|
|
9
|
-
|
10
|
-
|
6
|
+
let(:collection) { server.collection('collection1') }
|
7
|
+
|
8
|
+
def reload_collection
|
9
|
+
__memoized[:collection] = server.collection('collection1')
|
11
10
|
end
|
12
|
-
alias :reload_collection :load_collection
|
13
11
|
|
14
12
|
describe "naming support" do
|
15
|
-
it "demodulizes
|
16
|
-
LucidWorks::Synonym.model_name.
|
17
|
-
LucidWorks::Synonym.model_name.plural.should == "synonyms"
|
18
|
-
LucidWorks::Synonym.model_name.collection.should == "synonyms"
|
13
|
+
it "demodulizes the model's name" do
|
14
|
+
LucidWorks::Synonym.model_name.should == "Synonym"
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
22
18
|
describe "conversion support" do
|
23
19
|
it "can be converted to a key" do
|
24
|
-
synonym = LucidWorks::Synonym.new(:collection =>
|
20
|
+
synonym = LucidWorks::Synonym.new(:collection => collection, :mapping => "car, auto")
|
25
21
|
synonym.save
|
26
22
|
synonym.to_key.should == [8]
|
27
23
|
end
|
@@ -49,11 +45,12 @@ describe LucidWorks::Synonym do
|
|
49
45
|
|
50
46
|
describe :save do
|
51
47
|
context "when valid" do
|
52
|
-
subject { LucidWorks::Synonym.new(:collection =>
|
48
|
+
subject { LucidWorks::Synonym.new(:collection => collection, :mapping => "car, auto") }
|
53
49
|
|
54
50
|
it "gets saved in the collection settings" do
|
55
51
|
subject.save
|
56
|
-
reload_collection
|
52
|
+
reload_collection
|
53
|
+
collection.settings.synonym_list.should include("car, auto")
|
57
54
|
end
|
58
55
|
|
59
56
|
it "returns true" do
|
@@ -72,11 +69,12 @@ describe LucidWorks::Synonym do
|
|
72
69
|
end
|
73
70
|
|
74
71
|
context "when invalid" do
|
75
|
-
subject { LucidWorks::Synonym.new(:collection =>
|
72
|
+
subject { LucidWorks::Synonym.new(:collection => collection, :mapping => "car") }
|
76
73
|
|
77
74
|
it "doesn't get saved in the collection settings" do
|
78
75
|
subject.save
|
79
|
-
reload_collection
|
76
|
+
reload_collection
|
77
|
+
collection.settings.synonym_list.should_not include("car")
|
80
78
|
end
|
81
79
|
|
82
80
|
it "returns false" do
|
@@ -105,17 +103,20 @@ describe LucidWorks::Synonym do
|
|
105
103
|
|
106
104
|
describe :update_attributes do
|
107
105
|
it "updates the collection settings" do
|
108
|
-
|
109
|
-
|
110
|
-
|
106
|
+
first_default_synonym = collection.settings.synonym_list.first
|
107
|
+
LucidWorks::Synonym.new(:id => 0, :collection => collection, :mapping => first_default_synonym, :persisted => true).
|
108
|
+
update_attributes(:mapping => "lawyer, clown")
|
109
|
+
reload_collection
|
110
|
+
collection.settings.synonym_list.first.should == "lawyer, clown"
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
describe :destroy do
|
115
115
|
it "removes the mapping from the collection settings" do
|
116
|
-
|
117
|
-
|
118
|
-
|
116
|
+
first_default_synonym = collection.settings.synonym_list.first
|
117
|
+
LucidWorks::Synonym.new(:id => 0, :collection => collection, :mapping => first_default_synonym, :persisted => true).destroy
|
118
|
+
reload_collection
|
119
|
+
collection.settings.synonym_list.should_not include(first_default_synonym)
|
119
120
|
end
|
120
121
|
end
|
121
122
|
end
|