friendlyfashion-thinking-sphinx 2.0.13.3 → 2.0.14.1

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.
@@ -4,16 +4,16 @@ describe ThinkingSphinx::FacetSearch do
4
4
  let(:search) { stub('search', :append_to => nil, :empty? => true) }
5
5
  let(:config) { ThinkingSphinx::Configuration.instance }
6
6
  let(:client) { stub('client', :run => []) }
7
-
7
+
8
8
  before :each do
9
- config.stub!(:client => client)
9
+ ThinkingSphinx::Connection.stub!(:take).and_yield(client)
10
10
  end
11
-
11
+
12
12
  describe 'populate' do
13
13
  before :each do
14
14
  config.configuration.searchd.max_matches = 10_000
15
15
  end
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
19
  if Riddle.loaded_version.to_i < 2
@@ -22,28 +22,28 @@ describe ThinkingSphinx::FacetSearch do
22
22
  ThinkingSphinx::FacetSearch.new.facet_names.should == ['sphinx_internal_class']
23
23
  end
24
24
  end
25
-
25
+
26
26
  it "should request all facets in a multi-model request if specified" do
27
27
  ThinkingSphinx.stub!(:search => search)
28
28
  names = ThinkingSphinx::FacetSearch.new(:all_facets => true).facet_names
29
-
29
+
30
30
  if Riddle.loaded_version.to_i < 2
31
31
  names.should == ['class_crc', 'city_facet', 'state_facet', 'birthday']
32
32
  else
33
33
  names.should == ['sphinx_internal_class', 'city_facet', 'state_facet', 'birthday']
34
34
  end
35
35
  end
36
-
36
+
37
37
  it "should use the system-set max_matches for limit on facet calls" do
38
38
  ThinkingSphinx.should_receive(:search) do |options|
39
39
  options[:max_matches].should == 10_000
40
40
  options[:limit].should == 10_000
41
41
  search
42
42
  end
43
-
43
+
44
44
  ThinkingSphinx::FacetSearch.new
45
45
  end
46
-
46
+
47
47
  it "should use the default max-matches if there is no explicit setting" do
48
48
  config.configuration.searchd.max_matches = nil
49
49
  ThinkingSphinx.should_receive(:search) do |options|
@@ -51,32 +51,32 @@ describe ThinkingSphinx::FacetSearch do
51
51
  options[:limit].should == 1000
52
52
  search
53
53
  end
54
-
54
+
55
55
  ThinkingSphinx::FacetSearch.new
56
56
  end
57
-
57
+
58
58
  it "should ignore user-provided max_matches and limit on facet calls" do
59
59
  ThinkingSphinx.should_receive(:search) do |options|
60
60
  options[:max_matches].should == 10_000
61
61
  options[:limit].should == 10_000
62
62
  search
63
63
  end
64
-
64
+
65
65
  ThinkingSphinx::FacetSearch.new(
66
66
  :max_matches => 500,
67
67
  :limit => 200
68
68
  )
69
69
  end
70
-
70
+
71
71
  it "should not use an explicit :page" do
72
72
  ThinkingSphinx.should_receive(:search) do |options|
73
73
  options[:page].should == 1
74
74
  search
75
75
  end
76
-
76
+
77
77
  ThinkingSphinx::FacetSearch.new(:page => 3)
78
78
  end
79
-
79
+
80
80
  describe "conflicting facets" do
81
81
  before :each do
82
82
  @index = ThinkingSphinx::Index::Builder.generate(Alpha) do
@@ -84,28 +84,28 @@ describe ThinkingSphinx::FacetSearch do
84
84
  has :value, :as => :city, :facet => true
85
85
  end
86
86
  end
87
-
87
+
88
88
  after :each do
89
89
  Alpha.sphinx_facets.delete_at(-1)
90
90
  end
91
-
91
+
92
92
  it "should raise an error if searching with facets of same name but different type" do
93
93
  lambda {
94
94
  facets = ThinkingSphinx.facets :all_facets => true
95
95
  }.should raise_error
96
96
  end
97
97
  end
98
-
98
+
99
99
  describe ':facets option' do
100
100
  it "should limit facets to the requested set" do
101
101
  ThinkingSphinx.should_receive(:search).once.and_return(search)
102
-
102
+
103
103
  ThinkingSphinx::FacetSearch.new(
104
104
  :classes => [Person], :facets => :state
105
105
  )
106
106
  end
107
107
  end
108
-
108
+
109
109
  describe "empty result set for attributes" do
110
110
  before :each do
111
111
  ThinkingSphinx.stub!(:search => search)
@@ -113,7 +113,7 @@ describe ThinkingSphinx::FacetSearch do
113
113
  :classes => [Person], :facets => :state
114
114
  )
115
115
  end
116
-
116
+
117
117
  it "should add key as attribute" do
118
118
  @facets.should have_key(:state)
119
119
  end
@@ -131,7 +131,7 @@ describe ThinkingSphinx::FacetSearch do
131
131
  search.stub!(:each_with_match).
132
132
  and_yield(@person, {:attributes => {'@groupby' => @person.city.to_crc32, '@count' => 1}})
133
133
  ThinkingSphinx::Search.stub!(:bundle_searches => [search])
134
-
134
+
135
135
  @facets = ThinkingSphinx::FacetSearch.new(
136
136
  :classes => [Person], :facets => :city
137
137
  )
@@ -150,7 +150,7 @@ describe ThinkingSphinx::FacetSearch do
150
150
  end
151
151
  end
152
152
  end
153
-
153
+
154
154
  describe "#for" do
155
155
  before do
156
156
  @person = Person.find(:first)
@@ -158,7 +158,7 @@ describe ThinkingSphinx::FacetSearch do
158
158
  search.stub!(:each_with_match).
159
159
  and_yield(@person, {:attributes => {'@groupby' => @person.city.to_crc32, '@count' => 1}})
160
160
  ThinkingSphinx::Search.stub!(:bundle_searches => [search])
161
-
161
+
162
162
  @facets = ThinkingSphinx::FacetSearch.new(
163
163
  :classes => [Person], :facets => :city
164
164
  )
@@ -169,7 +169,7 @@ describe ThinkingSphinx::FacetSearch do
169
169
  options[:with].should have_key('city_facet')
170
170
  options[:with]['city_facet'].should == @person.city.to_crc32
171
171
  end
172
-
172
+
173
173
  @facets.for(:city => @person.city)
174
174
  end
175
175
  end
@@ -4,150 +4,150 @@ describe ThinkingSphinx::SearchMethods do
4
4
  it "should be included into models with indexes" do
5
5
  Alpha.included_modules.should include(ThinkingSphinx::SearchMethods)
6
6
  end
7
-
7
+
8
8
  it "should not be included into models that don't have indexes" do
9
9
  Gamma.included_modules.should_not include(ThinkingSphinx::SearchMethods)
10
10
  end
11
-
11
+
12
12
  describe '.search_context' do
13
13
  it "should return nil if not within a model" do
14
14
  ThinkingSphinx.search_context.should be_nil
15
15
  end
16
-
16
+
17
17
  it "should return the model if within one" do
18
18
  Alpha.search_context.should == Alpha
19
19
  end
20
20
  end
21
-
21
+
22
22
  describe '.search' do
23
23
  it "should return an instance of ThinkingSphinx::Search" do
24
24
  Alpha.search.class.should == ThinkingSphinx::Search
25
25
  end
26
-
26
+
27
27
  it "should set the classes option if not already set" do
28
28
  search = Alpha.search
29
29
  search.options[:classes].should == [Alpha]
30
30
  end
31
-
31
+
32
32
  it "shouldn't set the classes option if already defined" do
33
33
  search = Alpha.search :classes => [Beta]
34
34
  search.options[:classes].should == [Beta]
35
35
  end
36
-
36
+
37
37
  it "should default to nil for the classes options" do
38
38
  ThinkingSphinx.search.options[:classes].should be_nil
39
39
  end
40
40
  end
41
-
41
+
42
42
  describe '.search_for_ids' do
43
43
  it "should return an instance of ThinkingSphinx::Search" do
44
44
  Alpha.search.class.should == ThinkingSphinx::Search
45
45
  end
46
-
46
+
47
47
  it "should set the classes option if not already set" do
48
48
  search = Alpha.search_for_ids
49
49
  search.options[:classes].should == [Alpha]
50
50
  end
51
-
51
+
52
52
  it "shouldn't set the classes option if already defined" do
53
53
  search = Alpha.search_for_ids :classes => [Beta]
54
54
  search.options[:classes].should == [Beta]
55
55
  end
56
-
56
+
57
57
  it "should set ids_only to true" do
58
58
  search = Alpha.search_for_ids
59
59
  search.options[:ids_only].should be_true
60
60
  end
61
61
  end
62
-
62
+
63
63
  describe '.search_for_id' do
64
64
  before :each do
65
65
  @config = ThinkingSphinx::Configuration.instance
66
66
  @client = Riddle::Client.new
67
67
 
68
- @config.stub!(:client => @client)
68
+ ThinkingSphinx::Connection.stub!(:take).and_yield(@client)
69
69
  @client.stub!(:query => {:matches => [], :total_found => 0})
70
70
  end
71
-
71
+
72
72
  it "should set the id range to the given id value" do
73
73
  ThinkingSphinx.search_for_id(101, 'alpha_core')
74
-
74
+
75
75
  @client.id_range.should == (101..101)
76
76
  end
77
-
77
+
78
78
  it "should not make any calls to the database" do
79
79
  Alpha.should_not_receive(:find)
80
-
80
+
81
81
  ThinkingSphinx.search_for_id(101, 'alpha_core', :classes => [Alpha])
82
82
  end
83
-
83
+
84
84
  it "should return true if there is a record" do
85
85
  @client.stub!(:query => {:matches => [
86
86
  {:attributes => {'sphinx_internal_id' => 100}}
87
87
  ], :total_found => 1})
88
-
88
+
89
89
  ThinkingSphinx.search_for_id(101, 'alpha_core').should be_true
90
90
  end
91
-
91
+
92
92
  it "should return false if there isn't a record" do
93
93
  ThinkingSphinx.search_for_id(101, 'alpha_core').should be_false
94
94
  end
95
95
  end
96
-
96
+
97
97
  describe '.count' do
98
98
  before :each do
99
99
  @config = ThinkingSphinx::Configuration.instance
100
100
  @client = Riddle::Client.new
101
101
 
102
- @config.stub!(:client => @client)
102
+ ThinkingSphinx::Connection.stub!(:take).and_yield(@client)
103
103
  @client.stub!(:query => {:matches => [], :total_found => 42})
104
104
  end
105
-
105
+
106
106
  it "should fall through to ActiveRecord if called on a class" do
107
107
  @client.should_not_receive(:query)
108
-
108
+
109
109
  Alpha.count
110
110
  end
111
-
111
+
112
112
  it "should return the total number of results if called globally" do
113
113
  ThinkingSphinx.count.should == 42
114
114
  end
115
115
  end
116
-
116
+
117
117
  describe '.search_count' do
118
118
  before :each do
119
119
  @config = ThinkingSphinx::Configuration.instance
120
120
  @client = Riddle::Client.new
121
121
 
122
- @config.stub!(:client => @client)
122
+ ThinkingSphinx::Connection.stub!(:take).and_yield(@client)
123
123
  @client.stub!(:query => {:matches => [], :total_found => 42})
124
124
  end
125
-
125
+
126
126
  it "should return the total number of results" do
127
127
  Alpha.search_count.should == 42
128
128
  end
129
-
129
+
130
130
  it "should not make any calls to the database" do
131
131
  Alpha.should_not_receive(:find)
132
-
132
+
133
133
  Alpha.search_count
134
134
  end
135
135
  end
136
-
136
+
137
137
  describe '.facets' do
138
138
  before :each do
139
139
  ThinkingSphinx::Search.stub!(:bundle_searches => [])
140
140
  end
141
-
141
+
142
142
  it "should return a FacetSearch instance" do
143
143
  Alpha.facets.should be_a(ThinkingSphinx::FacetSearch)
144
144
  end
145
-
145
+
146
146
  it "should set the classes option if not already set" do
147
147
  facets = Alpha.facets
148
148
  facets.options[:classes].should == [Alpha]
149
149
  end
150
-
150
+
151
151
  it "shouldn't set the classes option if already defined" do
152
152
  facets = Alpha.facets :classes => [Beta]
153
153
  facets.options[:classes].should == [Beta]
@@ -6,18 +6,19 @@ describe ThinkingSphinx::Search do
6
6
  @config = ThinkingSphinx::Configuration.instance
7
7
  @client = Riddle::Client.new
8
8
 
9
- @config.stub!(:client => @client)
9
+ ThinkingSphinx::Connection.stub(:take).and_yield(@client)
10
+
10
11
  @client.stub!(:query => {:matches => [], :total_found => 41, :total => 41})
11
12
  end
12
13
 
13
14
  it "not request results from the client if not accessing items" do
14
- @config.should_not_receive(:client)
15
+ ThinkingSphinx::Connection.should_not_receive(:take)
15
16
 
16
17
  ThinkingSphinx::Search.new.class
17
18
  end
18
19
 
19
20
  it "should request results if access is required" do
20
- @config.should_receive(:client)
21
+ ThinkingSphinx::Connection.should_receive(:take).and_yield(@client)
21
22
 
22
23
  ThinkingSphinx::Search.new.first
23
24
  end
@@ -1433,19 +1434,6 @@ describe ThinkingSphinx::Search do
1433
1434
  @search.freeze.should be_a(ThinkingSphinx::Search)
1434
1435
  end
1435
1436
  end
1436
-
1437
- describe '#client' do
1438
- let(:client) { Riddle::Client.new }
1439
- it "should respect the client in options" do
1440
- search = ThinkingSphinx::Search.new :client => client
1441
- search.client.should == client
1442
- end
1443
-
1444
- it "should get a new client from the configuration singleton by default" do
1445
- ThinkingSphinx::Configuration.instance.stub!(:client => client)
1446
- ThinkingSphinx::Search.new.client.should == client
1447
- end
1448
- end
1449
1437
  end
1450
1438
 
1451
1439
  describe ThinkingSphinx::Search, "playing nice with Search model" do
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friendlyfashion-thinking-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.13.3
5
- prerelease:
4
+ version: 2.0.14.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Justas Janauskas
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-27 00:00:00.000000000 Z
11
+ date: 2013-03-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: riddle
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: builder
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,15 +48,27 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 2.1.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: innertube
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.2
62
69
  - !ruby/object:Gem::Dependency
63
70
  name: actionpack
64
71
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
72
  requirements:
67
73
  - - ! '>='
68
74
  - !ruby/object:Gem::Version
@@ -70,7 +76,6 @@ dependencies:
70
76
  type: :development
71
77
  prerelease: false
72
78
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
79
  requirements:
75
80
  - - ! '>='
76
81
  - !ruby/object:Gem::Version
@@ -78,7 +83,6 @@ dependencies:
78
83
  - !ruby/object:Gem::Dependency
79
84
  name: appraisal
80
85
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
86
  requirements:
83
87
  - - '='
84
88
  - !ruby/object:Gem::Version
@@ -86,7 +90,6 @@ dependencies:
86
90
  type: :development
87
91
  prerelease: false
88
92
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
93
  requirements:
91
94
  - - '='
92
95
  - !ruby/object:Gem::Version
@@ -94,7 +97,6 @@ dependencies:
94
97
  - !ruby/object:Gem::Dependency
95
98
  name: cucumber
96
99
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
100
  requirements:
99
101
  - - '='
100
102
  - !ruby/object:Gem::Version
@@ -102,7 +104,6 @@ dependencies:
102
104
  type: :development
103
105
  prerelease: false
104
106
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
107
  requirements:
107
108
  - - '='
108
109
  - !ruby/object:Gem::Version
@@ -110,7 +111,6 @@ dependencies:
110
111
  - !ruby/object:Gem::Dependency
111
112
  name: faker
112
113
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
@@ -118,7 +118,6 @@ dependencies:
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
121
  requirements:
123
122
  - - '='
124
123
  - !ruby/object:Gem::Version
@@ -126,7 +125,6 @@ dependencies:
126
125
  - !ruby/object:Gem::Dependency
127
126
  name: rake
128
127
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
128
  requirements:
131
129
  - - ! '>='
132
130
  - !ruby/object:Gem::Version
@@ -134,7 +132,6 @@ dependencies:
134
132
  type: :development
135
133
  prerelease: false
136
134
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
135
  requirements:
139
136
  - - ! '>='
140
137
  - !ruby/object:Gem::Version
@@ -142,7 +139,6 @@ dependencies:
142
139
  - !ruby/object:Gem::Dependency
143
140
  name: rspec
144
141
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
142
  requirements:
147
143
  - - '='
148
144
  - !ruby/object:Gem::Version
@@ -150,7 +146,6 @@ dependencies:
150
146
  type: :development
151
147
  prerelease: false
152
148
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
149
  requirements:
155
150
  - - '='
156
151
  - !ruby/object:Gem::Version
@@ -158,7 +153,6 @@ dependencies:
158
153
  - !ruby/object:Gem::Dependency
159
154
  name: will_paginate
160
155
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
156
  requirements:
163
157
  - - '='
164
158
  - !ruby/object:Gem::Version
@@ -166,7 +160,6 @@ dependencies:
166
160
  type: :development
167
161
  prerelease: false
168
162
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
163
  requirements:
171
164
  - - '='
172
165
  - !ruby/object:Gem::Version
@@ -174,7 +167,6 @@ dependencies:
174
167
  - !ruby/object:Gem::Dependency
175
168
  name: yard
176
169
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
170
  requirements:
179
171
  - - ! '>='
180
172
  - !ruby/object:Gem::Version
@@ -182,7 +174,6 @@ dependencies:
182
174
  type: :development
183
175
  prerelease: false
184
176
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
177
  requirements:
187
178
  - - ! '>='
188
179
  - !ruby/object:Gem::Version
@@ -219,6 +210,7 @@ files:
219
210
  - lib/thinking_sphinx/bundled_search.rb
220
211
  - lib/thinking_sphinx/class_facet.rb
221
212
  - lib/thinking_sphinx/configuration.rb
213
+ - lib/thinking_sphinx/connection.rb
222
214
  - lib/thinking_sphinx/context.rb
223
215
  - lib/thinking_sphinx/core/string.rb
224
216
  - lib/thinking_sphinx/deltas.rb
@@ -354,6 +346,7 @@ files:
354
346
  - spec/thinking_sphinx/attribute_spec.rb
355
347
  - spec/thinking_sphinx/auto_version_spec.rb
356
348
  - spec/thinking_sphinx/configuration_spec.rb
349
+ - spec/thinking_sphinx/connection_spec.rb
357
350
  - spec/thinking_sphinx/context_spec.rb
358
351
  - spec/thinking_sphinx/core/array_spec.rb
359
352
  - spec/thinking_sphinx/core/string_spec.rb
@@ -371,6 +364,7 @@ files:
371
364
  - spec/thinking_sphinx_spec.rb
372
365
  homepage: http://pat.github.com/ts/en/
373
366
  licenses: []
367
+ metadata: {}
374
368
  post_install_message: ! 'If you''re upgrading, you should read this:
375
369
 
376
370
  http://pat.github.com/ts/en/upgrading.html
@@ -381,22 +375,20 @@ rdoc_options: []
381
375
  require_paths:
382
376
  - lib
383
377
  required_ruby_version: !ruby/object:Gem::Requirement
384
- none: false
385
378
  requirements:
386
379
  - - ! '>='
387
380
  - !ruby/object:Gem::Version
388
381
  version: '0'
389
382
  required_rubygems_version: !ruby/object:Gem::Requirement
390
- none: false
391
383
  requirements:
392
384
  - - ! '>='
393
385
  - !ruby/object:Gem::Version
394
386
  version: '0'
395
387
  requirements: []
396
388
  rubyforge_project: thinking-sphinx
397
- rubygems_version: 1.8.24
389
+ rubygems_version: 2.0.3
398
390
  signing_key:
399
- specification_version: 3
391
+ specification_version: 4
400
392
  summary: ActiveRecord/Rails Sphinx library
401
393
  test_files:
402
394
  - features/abstract_inheritance.feature
@@ -507,6 +499,7 @@ test_files:
507
499
  - spec/thinking_sphinx/attribute_spec.rb
508
500
  - spec/thinking_sphinx/auto_version_spec.rb
509
501
  - spec/thinking_sphinx/configuration_spec.rb
502
+ - spec/thinking_sphinx/connection_spec.rb
510
503
  - spec/thinking_sphinx/context_spec.rb
511
504
  - spec/thinking_sphinx/core/array_spec.rb
512
505
  - spec/thinking_sphinx/core/string_spec.rb