thinking-sphinx 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/README.textile +2 -0
  2. data/VERSION +1 -1
  3. data/features/searching_by_model.feature +13 -0
  4. data/features/support/env.rb +2 -1
  5. data/features/thinking_sphinx/db/fixtures/cats.rb +1 -1
  6. data/features/thinking_sphinx/db/fixtures/dogs.rb +1 -1
  7. data/features/thinking_sphinx/db/fixtures/foxes.rb +1 -1
  8. data/features/thinking_sphinx/db/fixtures/posts.rb +5 -1
  9. data/features/thinking_sphinx/db/migrations/create_posts.rb +1 -0
  10. data/features/thinking_sphinx/models/developer.rb +1 -0
  11. data/features/thinking_sphinx/models/music.rb +3 -1
  12. data/features/thinking_sphinx/models/post.rb +1 -0
  13. data/lib/thinking_sphinx.rb +2 -2
  14. data/lib/thinking_sphinx/active_record.rb +32 -2
  15. data/lib/thinking_sphinx/active_record/delta.rb +0 -27
  16. data/lib/thinking_sphinx/adapters/mysql_adapter.rb +4 -0
  17. data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +4 -0
  18. data/lib/thinking_sphinx/association.rb +55 -5
  19. data/lib/thinking_sphinx/attribute.rb +17 -10
  20. data/lib/thinking_sphinx/auto_version.rb +1 -1
  21. data/lib/thinking_sphinx/class_facet.rb +7 -3
  22. data/lib/thinking_sphinx/configuration.rb +3 -3
  23. data/lib/thinking_sphinx/facet.rb +1 -0
  24. data/lib/thinking_sphinx/facet_search.rb +5 -1
  25. data/lib/thinking_sphinx/field.rb +16 -0
  26. data/lib/thinking_sphinx/search.rb +21 -5
  27. data/lib/thinking_sphinx/sinatra.rb +7 -0
  28. data/lib/thinking_sphinx/source.rb +33 -2
  29. data/lib/thinking_sphinx/source/internal_properties.rb +8 -3
  30. data/lib/thinking_sphinx/source/sql.rb +10 -1
  31. data/spec/thinking_sphinx/attribute_spec.rb +86 -94
  32. data/spec/thinking_sphinx/auto_version_spec.rb +8 -0
  33. data/spec/thinking_sphinx/facet_search_spec.rb +12 -6
  34. data/spec/thinking_sphinx/index/builder_spec.rb +32 -29
  35. data/spec/thinking_sphinx/search_spec.rb +14 -11
  36. metadata +5 -4
@@ -46,6 +46,14 @@ describe ThinkingSphinx::AutoVersion do
46
46
  ThinkingSphinx::AutoVersion.detect
47
47
  end
48
48
 
49
+ it "should require 2.0.1 if using Sphinx 2.0.2 dev" do
50
+ ThinkingSphinx::AutoVersion.should_receive(:require).
51
+ with('riddle/2.0.1')
52
+
53
+ @config.stub!(:version => '2.0.2-dev')
54
+ ThinkingSphinx::AutoVersion.detect
55
+ end
56
+
49
57
  it "should output a warning if the detected version is unsupported" do
50
58
  STDERR.should_receive(:puts).with(/unsupported/i)
51
59
 
@@ -16,16 +16,22 @@ describe ThinkingSphinx::FacetSearch do
16
16
 
17
17
  it "should request all shared facets in a multi-model request by default" do
18
18
  ThinkingSphinx.stub!(:search => search)
19
- ThinkingSphinx::FacetSearch.new.facet_names.should == ['class_crc']
19
+ if Riddle.loaded_version.to_i < 2
20
+ ThinkingSphinx::FacetSearch.new.facet_names.should == ['class_crc']
21
+ else
22
+ ThinkingSphinx::FacetSearch.new.facet_names.should == ['sphinx_internal_class']
23
+ end
20
24
  end
21
25
 
22
26
  it "should request all facets in a multi-model request if specified" do
23
27
  ThinkingSphinx.stub!(:search => search)
24
- ThinkingSphinx::FacetSearch.new(
25
- :all_facets => true
26
- ).facet_names.should == [
27
- 'class_crc', 'city_facet', 'state_facet', 'birthday'
28
- ]
28
+ names = ThinkingSphinx::FacetSearch.new(:all_facets => true).facet_names
29
+
30
+ if Riddle.loaded_version.to_i < 2
31
+ names.should == ['class_crc', 'city_facet', 'state_facet', 'birthday']
32
+ else
33
+ names.should == ['sphinx_internal_class', 'city_facet', 'state_facet', 'birthday']
34
+ end
29
35
  end
30
36
 
31
37
  it "should use the system-set max_matches for limit on facet calls" do
@@ -1,6 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ThinkingSphinx::Index::Builder do
4
+ let(:internal_attribute_count) {
5
+ Riddle.loaded_version.to_i < 2 ? 3 : 4
6
+ }
4
7
  describe ".generate without source scope" do
5
8
  before :each do
6
9
  @index = ThinkingSphinx::Index::Builder.generate(Person) do
@@ -31,10 +34,10 @@ describe ThinkingSphinx::Index::Builder do
31
34
  @source.fields[1].unique_name.should == :last_name
32
35
  end
33
36
 
34
- it "should have two attributes alongside the three internal ones" do
35
- @source.attributes.length.should == 5
36
- @source.attributes[3].unique_name.should == :birthday
37
- @source.attributes[4].unique_name.should == :internal_id
37
+ it "should have two attributes alongside the internal ones" do
38
+ @source.attributes.length.should == 2 + internal_attribute_count
39
+ @source.attributes[internal_attribute_count].unique_name.should == :birthday
40
+ @source.attributes[1 + internal_attribute_count].unique_name.should == :internal_id
38
41
  end
39
42
 
40
43
  it "should have one condition" do
@@ -95,8 +98,8 @@ describe ThinkingSphinx::Index::Builder do
95
98
  @source.fields.length.should == 1
96
99
  end
97
100
 
98
- it "should have one attribute alongside the three internal ones" do
99
- @source.attributes.length.should == 4
101
+ it "should have one attribute alongside the internal ones" do
102
+ @source.attributes.length.should == 1 + internal_attribute_count
100
103
  end
101
104
 
102
105
  it "should set the attribute name to have the _sort suffix" do
@@ -142,8 +145,8 @@ describe ThinkingSphinx::Index::Builder do
142
145
  @source.fields.length.should == 1
143
146
  end
144
147
 
145
- it "should have one attribute alongside the three internal ones" do
146
- @source.attributes.length.should == 4
148
+ it "should have one attribute alongside the internal ones" do
149
+ @source.attributes.length.should == 1 + internal_attribute_count
147
150
  end
148
151
 
149
152
  it "should set the attribute name to have the _facet suffix" do
@@ -174,8 +177,8 @@ describe ThinkingSphinx::Index::Builder do
174
177
  Alpha.sphinx_facets.delete_at(-1)
175
178
  end
176
179
 
177
- it "should have just one attribute alongside the three internal ones" do
178
- @source.attributes.length.should == 4
180
+ it "should have just one attribute alongside the internal ones" do
181
+ @source.attributes.length.should == 1 + internal_attribute_count
179
182
  end
180
183
  end
181
184
 
@@ -193,8 +196,8 @@ describe ThinkingSphinx::Index::Builder do
193
196
  Person.sphinx_facets.delete_at(-1)
194
197
  end
195
198
 
196
- it "should have just one attribute alongside the three internal ones" do
197
- @source.attributes.length.should == 4
199
+ it "should have just one attribute alongside the internal ones" do
200
+ @source.attributes.length.should == 1 + internal_attribute_count
198
201
  end
199
202
  end
200
203
 
@@ -212,8 +215,8 @@ describe ThinkingSphinx::Index::Builder do
212
215
  Beta.sphinx_facets.delete_at(-1)
213
216
  end
214
217
 
215
- it "should have just one attribute alongside the three internal ones" do
216
- @source.attributes.length.should == 4
218
+ it "should have just one attribute alongside the internal ones" do
219
+ @source.attributes.length.should == 1 + internal_attribute_count
217
220
  end
218
221
  end
219
222
 
@@ -231,8 +234,8 @@ describe ThinkingSphinx::Index::Builder do
231
234
  Alpha.sphinx_facets.delete_at(-1)
232
235
  end
233
236
 
234
- it "should have just one attribute alongside the three internal ones" do
235
- @source.attributes.length.should == 4
237
+ it "should have just one attribute alongside the internal ones" do
238
+ @source.attributes.length.should == 1 + internal_attribute_count
236
239
  end
237
240
  end
238
241
 
@@ -250,8 +253,8 @@ describe ThinkingSphinx::Index::Builder do
250
253
  Person.sphinx_facets.delete_at(-1)
251
254
  end
252
255
 
253
- it "should have two attributes alongside the three internal ones" do
254
- @source.attributes.length.should == 5
256
+ it "should have two attributes alongside the internal ones" do
257
+ @source.attributes.length.should == 2 + internal_attribute_count
255
258
  end
256
259
 
257
260
  it "should set the facet attribute name to have the _facet suffix" do
@@ -282,8 +285,8 @@ describe ThinkingSphinx::Index::Builder do
282
285
  Person.sphinx_facets.delete_at(-1)
283
286
  end
284
287
 
285
- it "should have two attributes alongside the three internal ones" do
286
- @source.attributes.length.should == 5
288
+ it "should have two attributes alongside the internal ones" do
289
+ @source.attributes.length.should == 2 + internal_attribute_count
287
290
  end
288
291
 
289
292
  it "should set the facet attribute name to have the _facet suffix" do
@@ -321,8 +324,8 @@ describe ThinkingSphinx::Index::Builder do
321
324
  @source.fields.length.should == 1
322
325
  end
323
326
 
324
- it "should have one attribute alongside the three internal ones" do
325
- @source.attributes.length.should == 4
327
+ it "should have one attribute alongside the internal ones" do
328
+ @source.attributes.length.should == 1 + internal_attribute_count
326
329
  end
327
330
 
328
331
  it "should set the attribute name to have the _facet suffix" do
@@ -381,10 +384,10 @@ describe ThinkingSphinx::Index::Builder do
381
384
  @source.fields[1].unique_name.should == :last_name
382
385
  end
383
386
 
384
- it "should have two attributes alongside the three internal ones" do
385
- @source.attributes.length.should == 5
386
- @source.attributes[3].unique_name.should == :birthday
387
- @source.attributes[4].unique_name.should == :internal_id
387
+ it "should have two attributes alongside the internal ones" do
388
+ @source.attributes.length.should == 2 + internal_attribute_count
389
+ @source.attributes[internal_attribute_count].unique_name.should == :birthday
390
+ @source.attributes[1 + internal_attribute_count].unique_name.should == :internal_id
388
391
  end
389
392
  end
390
393
 
@@ -418,12 +421,12 @@ describe ThinkingSphinx::Index::Builder do
418
421
  end
419
422
 
420
423
  it "should have two attributes alongside the six internal ones" do
421
- @index.attributes.length.should == 8
424
+ @index.attributes.length.should == 2 + (internal_attribute_count * 2)
422
425
  end
423
426
 
424
- it "should have one attribute in each source alongside the three internal ones" do
427
+ it "should have one attribute in each source alongside the internal ones" do
425
428
  @index.sources.each do |source|
426
- source.attributes.length.should == 4
429
+ source.attributes.length.should == 1 + internal_attribute_count
427
430
  end
428
431
  end
429
432
  end
@@ -1145,10 +1145,11 @@ describe ThinkingSphinx::Search do
1145
1145
  @client.stub! :query => {
1146
1146
  :matches => [{
1147
1147
  :attributes => {
1148
- 'sphinx_internal_id' => @alpha.id,
1149
- 'class_crc' => Alpha.to_crc32,
1150
- '@groupby' => 101,
1151
- '@count' => 5
1148
+ 'sphinx_internal_id' => @alpha.id,
1149
+ 'sphinx_internal_class' => 'Alpha',
1150
+ 'class_crc' => Alpha.to_crc32,
1151
+ '@groupby' => 101,
1152
+ '@count' => 5
1152
1153
  }
1153
1154
  }]
1154
1155
  }
@@ -1182,8 +1183,9 @@ describe ThinkingSphinx::Search do
1182
1183
  @client.stub! :query => {
1183
1184
  :matches => [{
1184
1185
  :attributes => {
1185
- 'sphinx_internal_id' => @alpha.id,
1186
- 'class_crc' => Alpha.to_crc32
1186
+ 'sphinx_internal_id' => @alpha.id,
1187
+ 'sphinx_internal_class' => 'Alpha',
1188
+ 'class_crc' => Alpha.to_crc32
1187
1189
  }, :weight => 12
1188
1190
  }]
1189
1191
  }
@@ -1207,11 +1209,12 @@ describe ThinkingSphinx::Search do
1207
1209
  @client.stub! :query => {
1208
1210
  :matches => [{
1209
1211
  :attributes => {
1210
- 'sphinx_internal_id' => @alpha.id,
1211
- 'class_crc' => Alpha.to_crc32,
1212
- '@geodist' => 101,
1213
- '@groupby' => 102,
1214
- '@count' => 103
1212
+ 'sphinx_internal_id' => @alpha.id,
1213
+ 'sphinx_internal_class' => 'Alpha',
1214
+ 'class_crc' => Alpha.to_crc32,
1215
+ '@geodist' => 101,
1216
+ '@groupby' => 102,
1217
+ '@count' => 103
1215
1218
  }, :weight => 12
1216
1219
  }]
1217
1220
  }
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: thinking-sphinx
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.0.4
5
+ version: 2.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Pat Allan
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-12 00:00:00 +10:00
13
+ date: 2011-05-25 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -31,7 +31,7 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 1.3.2
34
+ version: 1.3.3
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: *id002
@@ -240,6 +240,7 @@ files:
240
240
  - lib/thinking_sphinx/railtie.rb
241
241
  - lib/thinking_sphinx/search.rb
242
242
  - lib/thinking_sphinx/search_methods.rb
243
+ - lib/thinking_sphinx/sinatra.rb
243
244
  - lib/thinking_sphinx/source.rb
244
245
  - lib/thinking_sphinx/source/internal_properties.rb
245
246
  - lib/thinking_sphinx/source/sql.rb
@@ -378,7 +379,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
378
379
  requirements:
379
380
  - - ">="
380
381
  - !ruby/object:Gem::Version
381
- hash: -2581213737903947446
382
+ hash: 1998854075128866188
382
383
  segments:
383
384
  - 0
384
385
  version: "0"