sunspot_rails 2.1.0 → 2.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e4265b8bc7f396dcf434243ff31d073722ce37e4
4
+ data.tar.gz: 6a31e3de9ff96687f791fbca0ff71b29644a3b7e
5
+ SHA512:
6
+ metadata.gz: 476e1c959c213af1972a51abbd779a535d6b698544dc3a93348c4825433819b441cc082736ccbc73f44043ddfe5493f90cb0e963b0669e35b03d050322930516
7
+ data.tar.gz: e0afd66ab79b43f53df67f4434dface8feaed30185b2f3b21e4d150c6ffdb60ef63ba44f52c0ba6e3f35cdfb7aec927775c23ef19bd3c42494eb87e727ed954c
data/README.rdoc CHANGED
@@ -14,7 +14,7 @@ provides the following features:
14
14
  * Provide rake tasks for starting and stopping the development Solr instance,
15
15
  using the configuration in sunspot.yml
16
16
 
17
- Sunspot::Rails has been tested with Rails versions 2.3 and 3.0
17
+ Sunspot::Rails has been tested with Rails 3.0, 3.1, 3.2, and 4.0
18
18
 
19
19
  == Installation in Rails 3
20
20
 
data/Rakefile CHANGED
@@ -1,11 +1,5 @@
1
1
  require 'rake'
2
2
 
3
- begin
4
- require 'rdoc/task'
5
- rescue LoadError
6
- require 'rake/rdoctask'
7
- end
8
-
9
3
  if File.exist?(sunspot_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'sunspot', 'lib')))
10
4
  STDERR.puts("Using sunspot lib at #{sunspot_lib}")
11
5
  $: << sunspot_lib
data/dev_tasks/rdoc.rake CHANGED
@@ -1,16 +1,22 @@
1
- begin
2
- require 'hanna/rdoctask'
3
- rescue LoadError
4
- if require 'rubygems'
5
- retry
1
+ rdoc_task =
2
+ begin
3
+ require 'rdoc/task'
4
+ RDoc::Task
5
+ rescue LoadError
6
+ begin
7
+ require 'rake/rdoctask'
8
+ Rake::RDocTask
9
+ rescue
10
+ nil
11
+ end
6
12
  end
7
- # It's OK if hanna isn't installed.
8
- end
9
13
 
10
- Rake::RDocTask.new(:doc) do |rdoc|
11
- rdoc.main = 'README.md'
12
- rdoc.rdoc_files.include('README.md', 'lib/sunspot/rails/**/*.rb', 'lib/sunspot/rails.rb')
13
- rdoc.rdoc_dir = 'doc'
14
+ if rdoc_task
15
+ rdoc_task.new(:doc) do |rdoc|
16
+ rdoc.main = '../README.md'
17
+ rdoc.rdoc_files.include('../README.md', 'lib/sunspot/rails/**/*.rb', 'lib/sunspot/rails.rb')
18
+ rdoc.rdoc_dir = 'doc'
19
+ end
14
20
  end
15
21
 
16
22
  namespace :doc do
data/dev_tasks/spec.rake CHANGED
@@ -44,8 +44,7 @@ namespace :spec do
44
44
 
45
45
  task :initialize_database do
46
46
  if ENV['DB'] == 'postgres'
47
- sh "psql -c 'DROP DATABASE IF EXISTS sunspot_test;' -d template1"
48
- sh "psql -c 'create database sunspot_test;' -d template1"
47
+ sh "bundle exec rake db:test:prepare"
49
48
  end
50
49
  end
51
50
 
data/lib/sunspot/rails.rb CHANGED
@@ -43,10 +43,12 @@ module Sunspot #:nodoc:
43
43
 
44
44
  def master_config(sunspot_rails_configuration)
45
45
  config = Sunspot::Configuration.build
46
- config.solr.url = URI::HTTP.build(
46
+ builder = sunspot_rails_configuration.scheme == 'http' ? URI::HTTP : URI::HTTPS
47
+ config.solr.url = builder.build(
47
48
  :host => sunspot_rails_configuration.master_hostname,
48
49
  :port => sunspot_rails_configuration.master_port,
49
- :path => sunspot_rails_configuration.master_path
50
+ :path => sunspot_rails_configuration.master_path,
51
+ :userinfo => sunspot_rails_configuration.userinfo
50
52
  ).to_s
51
53
  config.solr.read_timeout = sunspot_rails_configuration.read_timeout
52
54
  config.solr.open_timeout = sunspot_rails_configuration.open_timeout
@@ -55,10 +57,12 @@ module Sunspot #:nodoc:
55
57
 
56
58
  def slave_config(sunspot_rails_configuration)
57
59
  config = Sunspot::Configuration.build
58
- config.solr.url = URI::HTTP.build(
60
+ builder = sunspot_rails_configuration.scheme == 'http' ? URI::HTTP : URI::HTTPS
61
+ config.solr.url = builder.build(
59
62
  :host => sunspot_rails_configuration.hostname,
60
63
  :port => sunspot_rails_configuration.port,
61
- :path => sunspot_rails_configuration.path
64
+ :path => sunspot_rails_configuration.path,
65
+ :userinfo => sunspot_rails_configuration.userinfo
62
66
  ).to_s
63
67
  config.solr.read_timeout = sunspot_rails_configuration.read_timeout
64
68
  config.solr.open_timeout = sunspot_rails_configuration.open_timeout
@@ -25,6 +25,9 @@ module Sunspot #:nodoc:
25
25
  # read_timeout: 2
26
26
  # production:
27
27
  # solr:
28
+ # scheme: http
29
+ # user: username
30
+ # pass: password
28
31
  # hostname: localhost
29
32
  # port: 8983
30
33
  # path: /solr/myindex
@@ -67,7 +70,7 @@ module Sunspot #:nodoc:
67
70
  end
68
71
  @hostname
69
72
  end
70
-
73
+
71
74
  #
72
75
  # The port at which to connect to Solr.
73
76
  # Defaults to 8981 in test, 8982 in development and 8983 in production.
@@ -86,6 +89,42 @@ module Sunspot #:nodoc:
86
89
  @port
87
90
  end
88
91
 
92
+ #
93
+ # The scheme to use, http or https.
94
+ # Defaults to http
95
+ #
96
+ # ==== Returns
97
+ #
98
+ # String:: scheme
99
+ #
100
+ def scheme
101
+ unless defined?(@scheme)
102
+ @scheme = solr_url.scheme if solr_url
103
+ @scheme ||= user_configuration_from_key('solr', 'scheme')
104
+ @scheme ||= default_scheme
105
+ end
106
+ @scheme
107
+ end
108
+
109
+ #
110
+ # The userinfo used for authentication, a colon-delimited string like "user:pass"
111
+ # Defaults to nil, which means no authentication
112
+ #
113
+ # ==== Returns
114
+ #
115
+ # String:: userinfo
116
+ #
117
+ def userinfo
118
+ unless defined?(@userinfo)
119
+ @userinfo = solr_url.userinfo if solr_url
120
+ user = user_configuration_from_key('solr', 'user')
121
+ pass = user_configuration_from_key('solr', 'pass')
122
+ @userinfo ||= [ user, pass ].compact.join(":") if user && pass
123
+ @userinfo ||= default_userinfo
124
+ end
125
+ @userinfo
126
+ end
127
+
89
128
  #
90
129
  # The url path to the Solr servlet (useful if you are running multicore).
91
130
  # Default '/solr/default'.
@@ -153,7 +192,7 @@ module Sunspot #:nodoc:
153
192
  #
154
193
  # The default log_level that should be passed to solr. You can
155
194
  # change the individual log_levels in the solr admin interface.
156
- # If no level is specified in the sunspot configuration file,
195
+ # If no level is specified in the sunspot configuration file,
157
196
  # use a level similar to Rails own logging level.
158
197
  #
159
198
  # ==== Returns
@@ -166,39 +205,39 @@ module Sunspot #:nodoc:
166
205
  LOG_LEVELS[::Rails.logger.level]
167
206
  )
168
207
  end
169
-
208
+
170
209
  #
171
210
  # Should the solr index receive a commit after each http-request.
172
211
  # Default true
173
212
  #
174
213
  # ==== Returns
175
- #
214
+ #
176
215
  # Boolean: auto_commit_after_request?
177
216
  #
178
217
  def auto_commit_after_request?
179
- @auto_commit_after_request ||=
218
+ @auto_commit_after_request ||=
180
219
  user_configuration_from_key('auto_commit_after_request') != false
181
220
  end
182
-
221
+
183
222
  #
184
223
  # As for #auto_commit_after_request? but only for deletes
185
224
  # Default false
186
225
  #
187
226
  # ==== Returns
188
- #
227
+ #
189
228
  # Boolean: auto_commit_after_delete_request?
190
229
  #
191
230
  def auto_commit_after_delete_request?
192
- @auto_commit_after_delete_request ||=
231
+ @auto_commit_after_delete_request ||=
193
232
  (user_configuration_from_key('auto_commit_after_delete_request') || false)
194
233
  end
195
-
196
-
234
+
235
+
197
236
  #
198
237
  # The log directory for solr logfiles
199
238
  #
200
239
  # ==== Returns
201
- #
240
+ #
202
241
  # String:: log_dir
203
242
  #
204
243
  def log_file
@@ -208,15 +247,15 @@ module Sunspot #:nodoc:
208
247
  def data_path
209
248
  @data_path ||= user_configuration_from_key('solr', 'data_path') || File.join(::Rails.root, 'solr', 'data', ::Rails.env)
210
249
  end
211
-
250
+
212
251
  def pid_dir
213
252
  @pid_dir ||= user_configuration_from_key('solr', 'pid_dir') || File.join(::Rails.root, 'solr', 'pids', ::Rails.env)
214
253
  end
215
254
 
216
-
217
- #
255
+
256
+ #
218
257
  # The solr home directory. Sunspot::Rails expects this directory
219
- # to contain a config, data and pids directory. See
258
+ # to contain a config, data and pids directory. See
220
259
  # Sunspot::Rails::Server.bootstrap for more information.
221
260
  #
222
261
  # ==== Returns
@@ -232,21 +271,21 @@ module Sunspot #:nodoc:
232
271
  end
233
272
  end
234
273
 
235
- #
274
+ #
236
275
  # Solr start jar
237
276
  #
238
277
  def solr_jar
239
278
  @solr_jar ||= user_configuration_from_key('solr', 'solr_jar')
240
279
  end
241
280
 
242
- #
281
+ #
243
282
  # Minimum java heap size for Solr instance
244
283
  #
245
284
  def min_memory
246
285
  @min_memory ||= user_configuration_from_key('solr', 'min_memory')
247
286
  end
248
287
 
249
- #
288
+ #
250
289
  # Maximum java heap size for Solr instance
251
290
  #
252
291
  def max_memory
@@ -259,7 +298,7 @@ module Sunspot #:nodoc:
259
298
  def bind_address
260
299
  @bind_address ||= user_configuration_from_key('solr', 'bind_address')
261
300
  end
262
-
301
+
263
302
  def read_timeout
264
303
  @read_timeout ||= user_configuration_from_key('solr', 'read_timeout')
265
304
  end
@@ -277,9 +316,9 @@ module Sunspot #:nodoc:
277
316
  end
278
317
 
279
318
  private
280
-
319
+
281
320
  #
282
- # Logging in rails_root/log as solr_<environment>.log as a
321
+ # Logging in rails_root/log as solr_<environment>.log as a
283
322
  # default.
284
323
  #
285
324
  # ===== Returns
@@ -289,8 +328,8 @@ module Sunspot #:nodoc:
289
328
  def default_log_file_location
290
329
  File.join(::Rails.root, 'log', "solr_" + ::Rails.env + ".log")
291
330
  end
292
-
293
- #
331
+
332
+ #
294
333
  # return a specific key from the user configuration in config/sunspot.yml
295
334
  #
296
335
  # ==== Returns
@@ -302,7 +341,7 @@ module Sunspot #:nodoc:
302
341
  hash[key] if hash
303
342
  end
304
343
  end
305
-
344
+
306
345
  #
307
346
  # Memoized hash of configuration options for the current Rails environment
308
347
  # as specified in config/sunspot.yml
@@ -325,36 +364,44 @@ module Sunspot #:nodoc:
325
364
  end
326
365
  end
327
366
  end
328
-
367
+
329
368
  protected
330
-
369
+
331
370
  #
332
371
  # When a specific hostname, port and path aren't provided in the
333
372
  # sunspot.yml file, look for a key named 'url', then check the
334
373
  # environment, then fall back to a sensible localhost default.
335
374
  #
336
-
375
+
337
376
  def solr_url
338
377
  if ENV['SOLR_URL'] || ENV['WEBSOLR_URL']
339
378
  URI.parse(ENV['SOLR_URL'] || ENV['WEBSOLR_URL'])
340
379
  end
341
380
  end
342
-
381
+
343
382
  def default_hostname
344
383
  'localhost'
345
384
  end
346
-
385
+
347
386
  def default_port
348
387
  { 'test' => 8981,
349
388
  'development' => 8982,
350
389
  'production' => 8983
351
390
  }[::Rails.env] || 8983
352
391
  end
353
-
392
+
393
+ def default_scheme
394
+ 'http'
395
+ end
396
+
397
+ def default_userinfo
398
+ nil
399
+ end
400
+
354
401
  def default_path
355
402
  '/solr/default'
356
403
  end
357
-
404
+
358
405
  end
359
406
  end
360
407
  end
@@ -7,6 +7,10 @@ module Sunspot
7
7
  @original_session = original_session
8
8
  end
9
9
 
10
+ def batch
11
+ yield
12
+ end
13
+
10
14
  def index(*objects)
11
15
  end
12
16
 
@@ -31,6 +35,9 @@ module Sunspot
31
35
  def remove_all!(clazz = nil)
32
36
  end
33
37
 
38
+ def optimize
39
+ end
40
+
34
41
  def dirty?
35
42
  false
36
43
  end
@@ -77,6 +84,7 @@ module Sunspot
77
84
  def hits(options = {})
78
85
  PaginatedCollection.new
79
86
  end
87
+ alias_method :raw_results, :hits
80
88
 
81
89
  def total
82
90
  0
@@ -5,7 +5,7 @@ namespace :sunspot do
5
5
  # conventions, in that the file name matches the defined class name. \
6
6
  # By default the indexing system works in batches of 50 records, you can \
7
7
  # set your own value for this by using the batch_size argument. You can \
8
- # also optionally define a list of models to separated by a forward slash '/'
8
+ # also optionally define a list of models separated by a plus sign '+'
9
9
  #
10
10
  # $ rake sunspot:reindex # reindex all models
11
11
  # $ rake sunspot:reindex[1000] # reindex in batches of 1000
@@ -72,7 +72,7 @@ namespace :sunspot do
72
72
 
73
73
  def sunspot_solr_in_load_path?
74
74
  # http://www.rubular.com/r/rJGDh7eOSc
75
- $:.any? { |path| path =~ %r{sunspot_solr(-[^/]+)?/lib$} }
75
+ $:.any? { |path| path.to_s =~ %r{sunspot_solr(-[^/]+)?/lib$} }
76
76
  end
77
77
 
78
78
  unless sunspot_solr_in_load_path?
data/lib/sunspot_rails.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  # This needs to be loaded before sunspot/search/paginated_collection
2
2
  # or #to_json gets defined in Object breaking delegation to Array via
3
3
  # method_missing
4
- require 'active_support/core_ext/object/to_json'
4
+ if Rails::VERSION::MAJOR > 4 || (Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 1)
5
+ require 'active_support/core_ext/object/json'
6
+ else
7
+ require 'active_support/core_ext/object/to_json'
8
+ end
5
9
 
6
10
  require 'sunspot/rails'
7
11
  require 'sunspot/rails/railtie'
@@ -5,15 +5,23 @@ describe Sunspot::Rails::Configuration, "default values without a sunspot.yml" d
5
5
  File.stub(:exist?).and_return(false) # simulate sunspot.yml not existing
6
6
  @config = Sunspot::Rails::Configuration.new
7
7
  end
8
-
8
+
9
9
  it "should handle the 'hostname' property when not set" do
10
10
  @config.hostname.should == 'localhost'
11
- end
12
-
11
+ end
12
+
13
13
  it "should handle the 'path' property when not set" do
14
14
  @config.path.should == '/solr/default'
15
15
  end
16
16
 
17
+ it "should set the scheme to http" do
18
+ @config.scheme.should == "http"
19
+ end
20
+
21
+ it "should not have userinfo" do
22
+ @config.userinfo.should be_nil
23
+ end
24
+
17
25
  describe "port" do
18
26
  it "should default to port 8981 in test" do
19
27
  ::Rails.stub(:env => 'test')
@@ -36,7 +44,7 @@ describe Sunspot::Rails::Configuration, "default values without a sunspot.yml" d
36
44
  @config.port.should == 8983
37
45
  end
38
46
  end
39
-
47
+
40
48
  it "should set the read timeout to nil when not set" do
41
49
  @config.read_timeout == nil
42
50
  end
@@ -49,11 +57,11 @@ describe Sunspot::Rails::Configuration, "default values without a sunspot.yml" d
49
57
  ::Rails.logger.stub(:level){ 3 }
50
58
  @config.log_level.should == 'SEVERE'
51
59
  end
52
-
60
+
53
61
  it "should handle the 'log_file' property" do
54
62
  @config.log_file.should =~ /log\/solr_test.log/
55
63
  end
56
-
64
+
57
65
  it "should handle the 'solr_home' property when not set" do
58
66
  Rails.should_receive(:root).at_least(1).and_return('/some/path')
59
67
  @config.solr_home.should == '/some/path/solr'
@@ -68,11 +76,11 @@ describe Sunspot::Rails::Configuration, "default values without a sunspot.yml" d
68
76
  Rails.should_receive(:root).at_least(1).and_return('/some/path')
69
77
  @config.pid_dir.should == '/some/path/solr/pids/test'
70
78
  end
71
-
79
+
72
80
  it "should handle the 'auto_commit_after_request' propery when not set" do
73
81
  @config.auto_commit_after_request?.should == true
74
82
  end
75
-
83
+
76
84
  it "should handle the 'auto_commit_after_delete_request' propery when not set" do
77
85
  @config.auto_commit_after_delete_request?.should == false
78
86
  end
@@ -92,6 +100,14 @@ describe Sunspot::Rails::Configuration, "user provided sunspot.yml" do
92
100
  @config = Sunspot::Rails::Configuration.new
93
101
  end
94
102
 
103
+ it "should handle the 'scheme' property when set" do
104
+ @config.scheme.should == "http"
105
+ end
106
+
107
+ it "should handle the 'user' and 'pass' properties when set" do
108
+ @config.userinfo.should == "user:pass"
109
+ end
110
+
95
111
  it "should handle the 'hostname' property when set" do
96
112
  @config.hostname.should == 'some.host'
97
113
  end
@@ -99,15 +115,15 @@ describe Sunspot::Rails::Configuration, "user provided sunspot.yml" do
99
115
  it "should handle the 'port' property when set" do
100
116
  @config.port.should == 1234
101
117
  end
102
-
118
+
103
119
  it "should handle the 'path' property when set" do
104
120
  @config.path.should == '/solr/idx'
105
121
  end
106
-
122
+
107
123
  it "should handle the 'log_level' propery when set" do
108
124
  @config.log_level.should == 'WARNING'
109
125
  end
110
-
126
+
111
127
  it "should handle the 'solr_home' propery when set" do
112
128
  @config.solr_home.should == '/my_superior_path'
113
129
  end
@@ -119,7 +135,7 @@ describe Sunspot::Rails::Configuration, "user provided sunspot.yml" do
119
135
  it "should handle the 'pid_dir' property when set" do
120
136
  @config.pid_dir.should == '/my_superior_path/pids'
121
137
  end
122
-
138
+
123
139
  it "should handle the 'solr_home' property when set" do
124
140
  @config.solr_home.should == '/my_superior_path'
125
141
  end
@@ -127,7 +143,7 @@ describe Sunspot::Rails::Configuration, "user provided sunspot.yml" do
127
143
  it "should handle the 'auto_commit_after_request' propery when set" do
128
144
  @config.auto_commit_after_request?.should == false
129
145
  end
130
-
146
+
131
147
  it "should handle the 'auto_commit_after_delete_request' propery when set" do
132
148
  @config.auto_commit_after_delete_request?.should == true
133
149
  end
@@ -135,9 +151,11 @@ describe Sunspot::Rails::Configuration, "user provided sunspot.yml" do
135
151
  it "should handle the 'bind_address' property when set" do
136
152
  @config.bind_address.should == "127.0.0.1"
137
153
  end
154
+
138
155
  it "should handle the 'read_timeout' property when set" do
139
156
  @config.read_timeout.should == 2
140
157
  end
158
+
141
159
  it "should handle the 'open_timeout' property when set" do
142
160
  @config.open_timeout.should == 0.5
143
161
  end
@@ -163,7 +181,7 @@ describe Sunspot::Rails::Configuration, "with ENV['SOLR_URL'] overriding sunspot
163
181
  ::Rails.stub(:env => 'config_test')
164
182
  @config = Sunspot::Rails::Configuration.new
165
183
  end
166
-
184
+
167
185
  after(:all) do
168
186
  ENV.delete('SOLR_URL')
169
187
  end
@@ -175,7 +193,7 @@ describe Sunspot::Rails::Configuration, "with ENV['SOLR_URL'] overriding sunspot
175
193
  it "should handle the 'port' property when set" do
176
194
  @config.port.should == 5432
177
195
  end
178
-
196
+
179
197
  it "should handle the 'path' property when set" do
180
198
  @config.path.should == '/solr/env'
181
199
  end
@@ -190,7 +208,7 @@ describe Sunspot::Rails::Configuration, "with ENV['WEBSOLR_URL'] overriding suns
190
208
  ::Rails.stub(:env => 'config_test')
191
209
  @config = Sunspot::Rails::Configuration.new
192
210
  end
193
-
211
+
194
212
  after(:all) do
195
213
  ENV.delete('WEBSOLR_URL')
196
214
  end
@@ -202,9 +220,74 @@ describe Sunspot::Rails::Configuration, "with ENV['WEBSOLR_URL'] overriding suns
202
220
  it "should handle the 'port' property when set" do
203
221
  @config.port.should == 80
204
222
  end
205
-
223
+
224
+ it "should handle the 'path' property when set" do
225
+ @config.path.should == '/solr/a1b2c3d4e5f'
226
+ end
227
+ end
228
+
229
+ describe Sunspot::Rails::Configuration, "with ENV['WEBSOLR_URL'] using https" do
230
+ before(:all) do
231
+ ENV['WEBSOLR_URL'] = 'https://index.websolr.test/solr/a1b2c3d4e5f'
232
+ end
233
+
234
+ before(:each) do
235
+ ::Rails.stub(:env => 'config_test')
236
+ @config = Sunspot::Rails::Configuration.new
237
+ end
238
+
239
+ after(:all) do
240
+ ENV.delete('WEBSOLR_URL')
241
+ end
242
+
243
+ it "should set the scheme to https" do
244
+ @config.scheme.should == "https"
245
+ end
246
+
247
+ it "should handle the 'hostname' property when set" do
248
+ @config.hostname.should == 'index.websolr.test'
249
+ end
250
+
251
+ it "should handle the 'port' property when set" do
252
+ @config.port.should == 443
253
+ end
254
+
206
255
  it "should handle the 'path' property when set" do
207
256
  @config.path.should == '/solr/a1b2c3d4e5f'
208
257
  end
209
258
  end
210
259
 
260
+ describe Sunspot::Rails::Configuration, "with ENV['WEBSOLR_URL'] including userinfo" do
261
+ before(:all) do
262
+ ENV['WEBSOLR_URL'] = 'https://user:pass@index.websolr.test/solr/a1b2c3d4e5f'
263
+ end
264
+
265
+ before(:each) do
266
+ ::Rails.stub(:env => 'config_test')
267
+ @config = Sunspot::Rails::Configuration.new
268
+ end
269
+
270
+ after(:all) do
271
+ ENV.delete('WEBSOLR_URL')
272
+ end
273
+
274
+ it "should include username and passowrd" do
275
+ @config.userinfo.should == "user:pass"
276
+ end
277
+
278
+ it "should set the scheme to https" do
279
+ @config.scheme.should == "https"
280
+ end
281
+
282
+ it "should handle the 'hostname' property when set" do
283
+ @config.hostname.should == 'index.websolr.test'
284
+ end
285
+
286
+ it "should handle the 'port' property when set" do
287
+ @config.port.should == 443
288
+ end
289
+
290
+ it "should handle the 'path' property when set" do
291
+ @config.path.should == '/solr/a1b2c3d4e5f'
292
+ end
293
+ end
@@ -8,6 +8,9 @@ development:
8
8
  port: 8981
9
9
  config_test:
10
10
  solr:
11
+ scheme: http
12
+ user: user
13
+ pass: pass
11
14
  hostname: some.host
12
15
  port: 1234
13
16
  path: /solr/idx
@@ -9,6 +9,15 @@ describe 'specs with Sunspot stubbed' do
9
9
  @post = Post.create!
10
10
  end
11
11
 
12
+ it 'should batch' do
13
+ foo = mock('Foo')
14
+ block = lambda { foo.bar }
15
+
16
+ foo.should_receive(:bar)
17
+
18
+ Sunspot.batch(&block)
19
+ end
20
+
12
21
  it 'should not send index to session' do
13
22
  @session.should_not_receive(:index)
14
23
  @post.index
@@ -54,6 +63,11 @@ describe 'specs with Sunspot stubbed' do
54
63
  Post.remove_all_from_index!
55
64
  end
56
65
 
66
+ it 'should not send optimize to session' do
67
+ @session.should_not_receive(:optimize)
68
+ Sunspot.optimize
69
+ end
70
+
57
71
  it 'should return false for dirty?' do
58
72
  @session.should_not_receive(:dirty?)
59
73
  Sunspot.dirty?.should == false
@@ -107,6 +121,10 @@ describe 'specs with Sunspot stubbed' do
107
121
  @search.hits.should == []
108
122
  end
109
123
 
124
+ it 'should return the same for raw_results as hits' do
125
+ @search.raw_results.should == @search.hits
126
+ end
127
+
110
128
  it 'should return zero total' do
111
129
  @search.total.should == 0
112
130
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunspot_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
5
- prerelease:
4
+ version: 2.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mat Brown
@@ -27,86 +26,76 @@ authors:
27
26
  autorequire:
28
27
  bindir: bin
29
28
  cert_chain: []
30
- date: 2013-10-25 00:00:00.000000000 Z
29
+ date: 2014-05-07 00:00:00.000000000 Z
31
30
  dependencies:
32
31
  - !ruby/object:Gem::Dependency
33
32
  name: rails
34
33
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
34
  requirements:
37
- - - '>='
35
+ - - ">="
38
36
  - !ruby/object:Gem::Version
39
37
  version: '3'
40
38
  type: :runtime
41
39
  prerelease: false
42
40
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
41
  requirements:
45
- - - '>='
42
+ - - ">="
46
43
  - !ruby/object:Gem::Version
47
44
  version: '3'
48
45
  - !ruby/object:Gem::Dependency
49
46
  name: sunspot
50
47
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
48
  requirements:
53
49
  - - '='
54
50
  - !ruby/object:Gem::Version
55
- version: 2.1.0
51
+ version: 2.1.1
56
52
  type: :runtime
57
53
  prerelease: false
58
54
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
55
  requirements:
61
56
  - - '='
62
57
  - !ruby/object:Gem::Version
63
- version: 2.1.0
58
+ version: 2.1.1
64
59
  - !ruby/object:Gem::Dependency
65
60
  name: nokogiri
66
61
  requirement: !ruby/object:Gem::Requirement
67
- none: false
68
62
  requirements:
69
- - - '>='
63
+ - - ">="
70
64
  - !ruby/object:Gem::Version
71
65
  version: '0'
72
66
  type: :runtime
73
67
  prerelease: false
74
68
  version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
69
  requirements:
77
- - - '>='
70
+ - - ">="
78
71
  - !ruby/object:Gem::Version
79
72
  version: '0'
80
73
  - !ruby/object:Gem::Dependency
81
74
  name: rspec
82
75
  requirement: !ruby/object:Gem::Requirement
83
- none: false
84
76
  requirements:
85
- - - ~>
77
+ - - "~>"
86
78
  - !ruby/object:Gem::Version
87
79
  version: '1.2'
88
80
  type: :development
89
81
  prerelease: false
90
82
  version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
83
  requirements:
93
- - - ~>
84
+ - - "~>"
94
85
  - !ruby/object:Gem::Version
95
86
  version: '1.2'
96
87
  - !ruby/object:Gem::Dependency
97
88
  name: rspec-rails
98
89
  requirement: !ruby/object:Gem::Requirement
99
- none: false
100
90
  requirements:
101
- - - ~>
91
+ - - "~>"
102
92
  - !ruby/object:Gem::Version
103
93
  version: '1.2'
104
94
  type: :development
105
95
  prerelease: false
106
96
  version_requirements: !ruby/object:Gem::Requirement
107
- none: false
108
97
  requirements:
109
- - - ~>
98
+ - - "~>"
110
99
  - !ruby/object:Gem::Version
111
100
  version: '1.2'
112
101
  description: |2
@@ -122,8 +111,8 @@ executables: []
122
111
  extensions: []
123
112
  extra_rdoc_files: []
124
113
  files:
125
- - .gitignore
126
- - .rspec
114
+ - ".gitignore"
115
+ - ".rspec"
127
116
  - History.txt
128
117
  - LICENSE
129
118
  - MIT-LICENSE
@@ -193,32 +182,31 @@ files:
193
182
  homepage: http://github.com/outoftime/sunspot/tree/master/sunspot_rails
194
183
  licenses:
195
184
  - MIT
185
+ metadata: {}
196
186
  post_install_message:
197
187
  rdoc_options:
198
- - --webcvs=http://github.com/outoftime/sunspot/tree/master/%s
199
- - --title
188
+ - "--webcvs=http://github.com/outoftime/sunspot/tree/master/%s"
189
+ - "--title"
200
190
  - Sunspot-Rails - Rails integration for the Sunspot Solr search library - API Documentation
201
- - --main
191
+ - "--main"
202
192
  - README.rdoc
203
193
  require_paths:
204
194
  - lib
205
195
  required_ruby_version: !ruby/object:Gem::Requirement
206
- none: false
207
196
  requirements:
208
- - - '>='
197
+ - - ">="
209
198
  - !ruby/object:Gem::Version
210
199
  version: '0'
211
200
  required_rubygems_version: !ruby/object:Gem::Requirement
212
- none: false
213
201
  requirements:
214
- - - '>='
202
+ - - ">="
215
203
  - !ruby/object:Gem::Version
216
204
  version: '0'
217
205
  requirements: []
218
206
  rubyforge_project: sunspot
219
- rubygems_version: 1.8.25
207
+ rubygems_version: 2.2.2
220
208
  signing_key:
221
- specification_version: 3
209
+ specification_version: 4
222
210
  summary: Rails integration for the Sunspot Solr search library
223
211
  test_files:
224
212
  - spec/configuration_spec.rb