rsolr 1.1.1.pre1 → 1.1.1.pre2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93c229e0cee96690d0cf15464b218bab708d4140
4
- data.tar.gz: c910de4e9d7c29222713d671f37997eadbf51e4a
3
+ metadata.gz: bb1fa153ec3008beae75f53b9bb5e278bd68e2c3
4
+ data.tar.gz: ba02544b8e06337e000b58c659d0d253b7c1315d
5
5
  SHA512:
6
- metadata.gz: 4f97b243fd8ce50b4b9ddcb401f511c3a7a10a59691774c39be08bdca527eab75741378b01410001bf403a6007030deb07161bfaa41f709c52d3d39dc422caf9
7
- data.tar.gz: ecd3144115f9f3e2891d7a1c7e7b0c96cd789950d6e13cc3fa99e7d9cf15e464ffacc8abd0b1e7ce122779bc2e5667f2b9655b8817cb9ed6c472c9ab7916a9ec
6
+ metadata.gz: 3c4d111f9477a3f7d3e4b47295e33153e3c1579cc3814fc4d85245ee862f255c3b69e1e350d2d1464c0411d8d8a8aee0a3c0c307f0d47981c67cf239b3df8bd6
7
+ data.tar.gz: be60888b05bd5184e61c090e80d82a3b7389abb06af77eea06d75c1ea45c50eda1d2672cadcd2432f8e02d6a33f12895e9dbd55981857f7106c593499f35b3fb
data/lib/rsolr/client.rb CHANGED
@@ -14,9 +14,9 @@ class RSolr::Client
14
14
  @default_wt = value
15
15
  end
16
16
  end
17
-
17
+
18
18
  attr_reader :connection, :uri, :proxy, :options, :update_path
19
-
19
+
20
20
  def initialize connection, options = {}
21
21
  @proxy = @uri = nil
22
22
  @connection = connection
@@ -28,23 +28,24 @@ class RSolr::Client
28
28
  proxy_url = options[:proxy].dup
29
29
  proxy_url << "/" unless proxy_url.nil? or proxy_url[-1] == ?/
30
30
  @proxy = RSolr::Uri.create proxy_url if proxy_url
31
+ elsif options[:proxy] == false
32
+ @proxy = false # used to avoid setting the proxy from the environment.
31
33
  end
32
34
  end
33
35
  @update_path = options.fetch(:update_path, 'update')
34
36
  @options = options
35
37
  end
36
-
38
+
37
39
  # returns the request uri object.
38
40
  def base_request_uri
39
41
  base_uri.request_uri if base_uri
40
42
  end
41
-
42
- # returns the uri proxy if present,
43
- # otherwise just the uri object.
43
+
44
+ # returns the RSolr::URI uri object.
44
45
  def base_uri
45
- @proxy ? @proxy : @uri
46
+ @uri
46
47
  end
47
-
48
+
48
49
  # Create the get, post, and head methods
49
50
  %W(get post head).each do |meth|
50
51
  class_eval <<-RUBY
@@ -53,7 +54,7 @@ class RSolr::Client
53
54
  end
54
55
  RUBY
55
56
  end
56
-
57
+
57
58
  # A paginated request method.
58
59
  # Converts the page and per_page
59
60
  # arguments into "rows" and "start".
@@ -63,9 +64,9 @@ class RSolr::Client
63
64
  raise "'rows' or 'start' params should not be set when using +paginate+" if ["start", "rows"].include?(opts[:params].keys)
64
65
  execute build_paginated_request(page, per_page, path, opts)
65
66
  end
66
-
67
+
67
68
  # POST XML messages to /update with optional params.
68
- #
69
+ #
69
70
  # http://wiki.apache.org/solr/UpdateXmlMessages#add.2BAC8-update
70
71
  #
71
72
  # If not set, opts[:headers] will be set to a hash with the key
@@ -82,22 +83,22 @@ class RSolr::Client
82
83
  opts[:headers]['Content-Type'] ||= 'text/xml'
83
84
  post opts.fetch(:path, update_path), opts
84
85
  end
85
-
86
- #
86
+
87
+ #
87
88
  # +add+ creates xml "add" documents and sends the xml data to the +update+ method
88
- #
89
+ #
89
90
  # http://wiki.apache.org/solr/UpdateXmlMessages#add.2BAC8-update
90
- #
91
+ #
91
92
  # single record:
92
- # solr.update(:id=>1, :name=>'one')
93
+ # solr.add(:id=>1, :name=>'one')
94
+ #
95
+ # add using an array
93
96
  #
94
- # update using an array
95
- #
96
- # solr.update(
97
+ # solr.add(
97
98
  # [{:id=>1, :name=>'one'}, {:id=>2, :name=>'two'}],
98
99
  # :add_attributes => {:boost=>5.0, :commitWithin=>10}
99
100
  # )
100
- #
101
+ #
101
102
  def add doc, opts = {}
102
103
  add_attributes = opts.delete :add_attributes
103
104
  update opts.merge(:data => xml.add(doc, add_attributes))
@@ -120,16 +121,16 @@ class RSolr::Client
120
121
  optimize_attributes = opts.delete :optimize_attributes
121
122
  update opts.merge(:data => xml.optimize(optimize_attributes))
122
123
  end
123
-
124
+
124
125
  # send </rollback>
125
- #
126
+ #
126
127
  # http://wiki.apache.org/solr/UpdateXmlMessages#A.22rollback.22
127
- #
128
+ #
128
129
  # NOTE: solr 1.4 only
129
130
  def rollback opts = {}
130
131
  update opts.merge(:data => xml.rollback)
131
132
  end
132
-
133
+
133
134
  # Delete one or many documents by id
134
135
  # solr.delete_by_id 10
135
136
  # solr.delete_by_id([12, 41, 199])
@@ -138,22 +139,22 @@ class RSolr::Client
138
139
  end
139
140
 
140
141
  # delete one or many documents by query.
141
- #
142
+ #
142
143
  # http://wiki.apache.org/solr/UpdateXmlMessages#A.22delete.22_by_ID_and_by_Query
143
- #
144
+ #
144
145
  # solr.delete_by_query 'available:0'
145
146
  # solr.delete_by_query ['quantity:0', 'manu:"FQ"']
146
147
  def delete_by_query query, opts = {}
147
148
  update opts.merge(:data => xml.delete_by_query(query))
148
149
  end
149
-
150
+
150
151
  # shortcut to RSolr::Xml::Generator
151
152
  def xml
152
153
  @xml ||= RSolr::Xml::Generator.new
153
154
  end
154
-
155
+
155
156
  # +send_and_receive+ is the main request method responsible for sending requests to the +connection+ object.
156
- #
157
+ #
157
158
  # "path" : A string value that usually represents a solr request handler
158
159
  # "opts" : A hash, which can contain the following keys:
159
160
  # :method : required - the http method (:get, :post or :head)
@@ -161,7 +162,7 @@ class RSolr::Client
161
162
  # :data : optional - post data -- if a hash is given, it's sent as "application/x-www-form-urlencoded; charset=UTF-8"
162
163
  # :headers : optional - hash of request headers
163
164
  # All other options are passed right along to the connection's +send_and_receive+ method (:get, :post, or :head)
164
- #
165
+ #
165
166
  # +send_and_receive+ returns either a string or hash on a successful ruby request.
166
167
  # When the :params[:wt] => :ruby, the response will be a hash, else a string.
167
168
  #
@@ -171,13 +172,10 @@ class RSolr::Client
171
172
  # then passes the request/response into +adapt_response+.
172
173
  def send_and_receive path, opts
173
174
  request_context = build_request path, opts
174
- [:open_timeout, :read_timeout, :retry_503, :retry_after_limit].each do |k|
175
- request_context[k] = @options[k]
176
- end
177
175
  execute request_context
178
176
  end
179
-
180
- #
177
+
178
+ #
181
179
  def execute request_context
182
180
 
183
181
  raw_response = connection.execute self, request_context
@@ -214,13 +212,13 @@ class RSolr::Client
214
212
  retry_after_date = DateTime.parse(retry_after)
215
213
  retry_after = retry_after_date.to_time - Time.now
216
214
  retry_after = nil if retry_after < 0
217
- rescue ArgumentError => e
215
+ rescue ArgumentError
218
216
  retry_after = retry_after.to_i
219
217
  end
220
218
  end
221
219
  retry_after
222
220
  end
223
-
221
+
224
222
  # +build_request+ accepts a path and options hash,
225
223
  # then prepares a normalized hash to return for sending
226
224
  # to a solr connection driver.
@@ -251,6 +249,11 @@ class RSolr::Client
251
249
  end
252
250
  opts[:path] = path
253
251
  opts[:uri] = base_uri.merge(path.to_s + (query ? "?#{query}" : "")) if base_uri
252
+
253
+ [:open_timeout, :read_timeout, :retry_503, :retry_after_limit].each do |k|
254
+ opts[k] = @options[k]
255
+ end
256
+
254
257
  opts
255
258
  end
256
259
 
@@ -307,7 +310,7 @@ class RSolr::Client
307
310
  send_and_receive name, *args
308
311
  end
309
312
  end
310
-
313
+
311
314
  # evaluates the response[:body],
312
315
  # attempts to bring the ruby string to life.
313
316
  # If a SyntaxError is raised, then
@@ -15,7 +15,7 @@ class RSolr::Connection
15
15
  response = h.request request
16
16
  charset = response.type_params["charset"]
17
17
  {:status => response.code.to_i, :headers => response.to_hash, :body => force_charset(response.body, charset)}
18
- rescue Errno::ECONNREFUSED => e
18
+ rescue Errno::ECONNREFUSED
19
19
  raise RSolr::Error::ConnectionRefused, request_context.inspect
20
20
  # catch the undefined closed? exception -- this is a confirmed ruby bug
21
21
  rescue NoMethodError => e
@@ -29,22 +29,20 @@ class RSolr::Connection
29
29
 
30
30
  # This returns a singleton of a Net::HTTP or Net::HTTP.Proxy request object.
31
31
  def http uri, proxy = nil, read_timeout = nil, open_timeout = nil
32
- @http ||= (
33
- http = if proxy
34
- proxy_user, proxy_pass = proxy.userinfo.split(/:/) if proxy.userinfo
35
- Net::HTTP.Proxy(proxy.host, proxy.port, proxy_user, proxy_pass).new uri.host, uri.port
36
- elsif proxy == false
37
- # If explicitly passing in false, make sure we set proxy_addr to nil
38
- # to tell Net::HTTP to *not* use the environment proxy variables.
39
- Net::HTTP.new uri.host, uri.port, nil
40
- else
41
- Net::HTTP.new uri.host, uri.port
42
- end
43
- http.use_ssl = uri.port == 443 || uri.instance_of?(URI::HTTPS)
44
- http.read_timeout = read_timeout if read_timeout
45
- http.open_timeout = open_timeout if open_timeout
46
- http
47
- )
32
+ http = if proxy
33
+ proxy_user, proxy_pass = proxy.userinfo.split(/:/) if proxy.userinfo
34
+ Net::HTTP.Proxy(proxy.host, proxy.port, proxy_user, proxy_pass).new uri.host, uri.port
35
+ elsif proxy == false
36
+ # If explicitly passing in false, make sure we set proxy_addr to nil
37
+ # to tell Net::HTTP to *not* use the environment proxy variables.
38
+ Net::HTTP.new uri.host, uri.port, nil
39
+ else
40
+ Net::HTTP.new uri.host, uri.port
41
+ end
42
+ http.use_ssl = uri.port == 443 || uri.instance_of?(URI::HTTPS)
43
+ http.read_timeout = read_timeout if read_timeout
44
+ http.open_timeout = open_timeout if open_timeout
45
+ http
48
46
  end
49
47
 
50
48
  #
data/lib/rsolr/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module RSolr
2
- VERSION = "1.1.1.pre1"
2
+ VERSION = "1.1.1.pre2"
3
3
 
4
4
  def self.version
5
5
  VERSION
data/lib/rsolr/xml.rb CHANGED
@@ -51,10 +51,13 @@ module RSolr::Xml
51
51
  private
52
52
 
53
53
  def format_value(v)
54
- if v.is_a?(Date) && !v.is_a?(DateTime)
55
- Time.utc(v.year, v.mon, v.mday).iso8601
56
- elsif v.respond_to?(:to_time) && v.to_time
54
+ case v
55
+ when Time
56
+ v.getutc.iso8601
57
+ when DateTime
57
58
  v.to_time.getutc.iso8601
59
+ when Date
60
+ Time.utc(v.year, v.mon, v.mday).iso8601
58
61
  else
59
62
  v.to_s
60
63
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
  describe "RSolr::Client" do
3
-
3
+
4
4
  module ClientHelper
5
5
  def client
6
6
  @client ||= (
@@ -8,30 +8,52 @@ describe "RSolr::Client" do
8
8
  RSolr::Client.new connection, :url => "http://localhost:9999/solr", :read_timeout => 42, :open_timeout=>43
9
9
  )
10
10
  end
11
+
12
+ def client_with_proxy
13
+ @client_with_proxy ||= (
14
+ connection = RSolr::Connection.new
15
+ RSolr::Client.new connection, :url => "http://localhost:9999/solr", :proxy => 'http://localhost:8080', :read_timeout => 42, :open_timeout=>43
16
+ )
17
+ end
11
18
  end
12
-
19
+
13
20
  context "initialize" do
14
21
  it "should accept whatevs and set it as the @connection" do
15
22
  expect(RSolr::Client.new(:whatevs).connection).to eq(:whatevs)
16
23
  end
17
-
24
+
18
25
  it "should use :update_path from options" do
19
26
  client = RSolr::Client.new(:whatevs, { update_path: 'update_test' })
20
27
  expect(client.update_path).to eql('update_test')
21
28
  end
22
-
29
+
23
30
  it "should use 'update' for update_path by default" do
24
31
  client = RSolr::Client.new(:whatevs)
25
32
  expect(client.update_path).to eql('update')
26
33
  end
34
+
35
+ it "should use :proxy from options" do
36
+ client = RSolr::Client.new(:whatevs, { proxy: 'http://my.proxy/' })
37
+ expect(client.proxy.to_s).to eql('http://my.proxy/')
38
+ end
39
+
40
+ it "should use 'nil' for proxy by default" do
41
+ client = RSolr::Client.new(:whatevs)
42
+ expect(client.proxy).to be_nil
43
+ end
44
+
45
+ it "should use 'false' for proxy if passed 'false'" do
46
+ client = RSolr::Client.new(:whatevs, { proxy: false })
47
+ expect(client.proxy).to eq(false)
48
+ end
27
49
  end
28
-
50
+
29
51
  context "send_and_receive" do
30
52
  include ClientHelper
31
53
  it "should forward these method calls the #connection object" do
32
54
  [:get, :post, :head].each do |meth|
33
55
  expect(client.connection).to receive(:execute).
34
- and_return({:status => 200, :body => "{}", :headers => {}})
56
+ and_return({:status => 200, :body => "{}", :headers => {}})
35
57
  client.send_and_receive '', :method => meth, :params => {}, :data => nil, :headers => {}
36
58
  end
37
59
  end
@@ -87,17 +109,17 @@ describe "RSolr::Client" do
87
109
  :status => 200,
88
110
  :headers => {"Content-Type"=>"text/plain"}
89
111
  )
90
- client.post "update", request_opts
112
+ client.post "update", request_opts
91
113
  end
92
114
  end
93
-
115
+
94
116
  context "xml" do
95
117
  include ClientHelper
96
118
  it "should return an instance of RSolr::Xml::Generator" do
97
119
  expect(client.xml).to be_a RSolr::Xml::Generator
98
120
  end
99
121
  end
100
-
122
+
101
123
  context "add" do
102
124
  include ClientHelper
103
125
  it "should send xml to the connection's #post method" do
@@ -109,19 +131,19 @@ describe "RSolr::Client" do
109
131
  :method => :post,
110
132
  :data => "<xml/>"
111
133
  })
112
- ).
113
- and_return(
114
- :body => "",
115
- :status => 200,
116
- :headers => {"Content-Type"=>"text/xml"}
117
- )
134
+ ).
135
+ and_return(
136
+ :body => "",
137
+ :status => 200,
138
+ :headers => {"Content-Type"=>"text/xml"}
139
+ )
118
140
  expect(client.xml).to receive(:add).
119
141
  with({:id=>1}, {:commitWith=>10}).
120
- and_return("<xml/>")
142
+ and_return("<xml/>")
121
143
  client.add({:id=>1}, :add_attributes => {:commitWith=>10})
122
144
  end
123
145
  end
124
-
146
+
125
147
  context "update" do
126
148
  include ClientHelper
127
149
  it "should send data to the connection's #post method" do
@@ -133,12 +155,12 @@ describe "RSolr::Client" do
133
155
  :method => :post,
134
156
  :data => "<optimize/>"
135
157
  })
136
- ).
137
- and_return(
138
- :body => "",
139
- :status => 200,
140
- :headers => {"Content-Type"=>"text/xml"}
141
- )
158
+ ).
159
+ and_return(
160
+ :body => "",
161
+ :status => 200,
162
+ :headers => {"Content-Type"=>"text/xml"}
163
+ )
142
164
  client.update(:data => "<optimize/>")
143
165
  end
144
166
 
@@ -147,14 +169,14 @@ describe "RSolr::Client" do
147
169
  expect(client).to receive(:update_path).and_return('update_test')
148
170
  client.update({})
149
171
  end
150
-
172
+
151
173
  it "should use path from opts" do
152
174
  expect(client).to receive(:post).with('update_opts', any_args)
153
175
  allow(client).to receive(:update_path).and_return('update_test')
154
176
  client.update({path: 'update_opts'})
155
177
  end
156
178
  end
157
-
179
+
158
180
  context "post based helper methods:" do
159
181
  include ClientHelper
160
182
  [:commit, :optimize, :rollback].each do |meth|
@@ -167,17 +189,17 @@ describe "RSolr::Client" do
167
189
  :method => :post,
168
190
  :data => "<?xml version=\"1.0\" encoding=\"UTF-8\"?><#{meth}/>"
169
191
  })
170
- ).
171
- and_return(
172
- :body => "",
173
- :status => 200,
174
- :headers => {"Content-Type"=>"text/xml"}
175
- )
192
+ ).
193
+ and_return(
194
+ :body => "",
195
+ :status => 200,
196
+ :headers => {"Content-Type"=>"text/xml"}
197
+ )
176
198
  client.send meth
177
199
  end
178
200
  end
179
201
  end
180
-
202
+
181
203
  context "delete_by_id" do
182
204
  include ClientHelper
183
205
  it "should send data to the connection's #post method" do
@@ -189,16 +211,16 @@ describe "RSolr::Client" do
189
211
  :method => :post,
190
212
  :data => "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><id>1</id></delete>"
191
213
  })
192
- ).
193
- and_return(
194
- :body => "",
195
- :status => 200,
196
- :headers => {"Content-Type"=>"text/xml"}
197
- )
214
+ ).
215
+ and_return(
216
+ :body => "",
217
+ :status => 200,
218
+ :headers => {"Content-Type"=>"text/xml"}
219
+ )
198
220
  client.delete_by_id 1
199
221
  end
200
222
  end
201
-
223
+
202
224
  context "delete_by_query" do
203
225
  include ClientHelper
204
226
  it "should send data to the connection's #post method" do
@@ -210,16 +232,16 @@ describe "RSolr::Client" do
210
232
  :method => :post,
211
233
  :data => "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query fq=\"category:&quot;trash&quot;\"/></delete>"
212
234
  })
213
- ).
214
- and_return(
215
- :body => "",
216
- :status => 200,
217
- :headers => {"Content-Type"=>"text/xml"}
218
- )
235
+ ).
236
+ and_return(
237
+ :body => "",
238
+ :status => 200,
239
+ :headers => {"Content-Type"=>"text/xml"}
240
+ )
219
241
  client.delete_by_query :fq => "category:\"trash\""
220
242
  end
221
243
  end
222
-
244
+
223
245
  context "adapt_response" do
224
246
  include ClientHelper
225
247
  it 'should not try to evaluate ruby when the :qt is not :ruby' do
@@ -227,13 +249,13 @@ describe "RSolr::Client" do
227
249
  result = client.adapt_response({:params=>{}}, {:status => 200, :body => body, :headers => {}})
228
250
  expect(result).to eq(body)
229
251
  end
230
-
252
+
231
253
  it 'should evaluate ruby responses when the :wt is :ruby' do
232
254
  body = '{"time"=>"NOW"}'
233
255
  result = client.adapt_response({:params=>{:wt=>:ruby}}, {:status => 200, :body => body, :headers => {}})
234
256
  expect(result).to eq({"time"=>"NOW"})
235
257
  end
236
-
258
+
237
259
  it 'should evaluate json responses when the :wt is :json' do
238
260
  body = '{"time": "NOW"}'
239
261
  result = client.adapt_response({:params=>{:wt=>:json}}, {:status => 200, :body => body, :headers => {}})
@@ -255,9 +277,9 @@ describe "RSolr::Client" do
255
277
  client.adapt_response({:params=>{:wt => :ruby}}, {:status => 200, :body => "<woops/>", :headers => {}})
256
278
  }.to raise_error RSolr::Error::InvalidRubyResponse
257
279
  end
258
-
280
+
259
281
  end
260
-
282
+
261
283
  context "indifferent access" do
262
284
  include ClientHelper
263
285
  it "should raise a RuntimeError if the #with_indifferent_access extension isn't loaded" do
@@ -322,5 +344,14 @@ describe "RSolr::Client" do
322
344
  expect(subject[:headers]).to eq({"Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8"})
323
345
  end
324
346
  end
347
+
348
+ it "should properly handle proxy configuration" do
349
+ result = client_with_proxy.build_request('select',
350
+ :method => :post,
351
+ :data => {:q=>'test', :fq=>[0,1]},
352
+ :headers => {}
353
+ )
354
+ result[:uri].to_s.should match /^http:\/\/localhost:9999\/solr\//
355
+ end
325
356
  end
326
357
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'base64'
3
3
 
4
4
  describe "RSolr::Connection" do
5
-
5
+
6
6
  context "setup_raw_request" do
7
7
  it "should set the correct request parameters" do
8
8
  c = RSolr::Connection.new
@@ -35,7 +35,7 @@ describe "RSolr::Connection" do
35
35
 
36
36
  let(:http) { double(Net::HTTP).as_null_object }
37
37
 
38
- subject { RSolr::Connection.new }
38
+ subject { RSolr::Connection.new }
39
39
 
40
40
  before do
41
41
  allow(Net::HTTP).to receive(:new) { http }
@@ -57,7 +57,7 @@ describe "RSolr::Connection" do
57
57
 
58
58
  let(:http) { double(Net::HTTP).as_null_object }
59
59
 
60
- subject { RSolr::Connection.new }
60
+ subject { RSolr::Connection.new }
61
61
 
62
62
  before do
63
63
  allow(Net::HTTP).to receive(:new) { http }
@@ -74,6 +74,32 @@ describe "RSolr::Connection" do
74
74
  end
75
75
  end
76
76
 
77
+ context "proxy configuration" do
78
+ let(:client) { double.as_null_object }
79
+
80
+ let(:http) { double(Net::HTTP).as_null_object }
81
+
82
+ let(:uri) { URI.parse("http://localhost/some_url") }
83
+ let(:proxy) { URI.parse("http://my.proxy/") }
84
+
85
+ subject { RSolr::Connection.new }
86
+
87
+ it "should use the default if no proxy is provided" do
88
+ expect(Net::HTTP).to receive(:new).with(uri.host, uri.port) { http }
89
+ subject.execute client, { :uri => uri, :method => :get }
90
+ end
91
+
92
+ it "should use the proxy if one is provided" do
93
+ expect(Net::HTTP).to receive(:Proxy).with(proxy.host, proxy.port, nil, nil) { http }
94
+ subject.execute client, { :uri => uri, :proxy => proxy, :method => :get }
95
+ end
96
+
97
+ it "should not use a proxy if proxy setting is false" do
98
+ expect(Net::HTTP).to receive(:new).with(uri.host, uri.port, nil) { http }
99
+ subject.execute client, { :uri => uri, :proxy => false, :method => :get }
100
+ end
101
+ end
102
+
77
103
  context "connection refused" do
78
104
  let(:client) { double.as_null_object }
79
105
 
@@ -81,7 +107,7 @@ describe "RSolr::Connection" do
81
107
  let(:request_context) {
82
108
  {:uri => URI.parse("http://localhost/some_uri"), :method => :get, :open_timeout => 42}
83
109
  }
84
- subject { RSolr::Connection.new }
110
+ subject { RSolr::Connection.new }
85
111
 
86
112
  before do
87
113
  allow(Net::HTTP).to receive(:new) { http }
@@ -95,14 +121,14 @@ describe "RSolr::Connection" do
95
121
  }.to raise_error(Errno::ECONNREFUSED, /#{request_context}/)
96
122
  end
97
123
  end
98
-
124
+
99
125
  describe "basic auth support" do
100
126
  let(:http) { double(Net::HTTP).as_null_object }
101
-
127
+
102
128
  before do
103
129
  allow(Net::HTTP).to receive(:new) { http }
104
130
  end
105
-
131
+
106
132
  it "sets the authorization header" do
107
133
  expect(http).to receive(:request) do |request|
108
134
  expect(request.fetch('authorization')).to eq("Basic #{Base64.encode64("joe:pass")}".strip)
@@ -11,6 +11,13 @@ describe "RSolr::Pagination" do
11
11
  expect(r[:uri].query).to match(/rows=25/)
12
12
  expect(r[:uri].query).to match(/start=50/)
13
13
  end
14
+
15
+ it 'passes through client options' do
16
+ c = RSolr::Client.new(nil, open_timeout: 5, read_timeout: 7)
17
+ r = c.build_paginated_request 3, 25, "select", {:params => {:q => "test"}}
18
+ expect(r[:open_timeout]).to eq(5)
19
+ expect(r[:read_timeout]).to eq(7)
20
+ end
14
21
  end
15
22
  context "paginate" do
16
23
  it "should build a paginated request context and call execute" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsolr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1.pre1
4
+ version: 1.1.1.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antoine Latter
@@ -29,7 +29,7 @@ authors:
29
29
  autorequire:
30
30
  bindir: bin
31
31
  cert_chain: []
32
- date: 2016-02-11 00:00:00.000000000 Z
32
+ date: 2016-02-22 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: builder