rsolr 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.txt +3 -0
- data/lib/rsolr/client.rb +8 -2
- data/lib/rsolr/version.rb +1 -1
- data/spec/api/client_spec.rb +33 -25
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a71555285360893206f2b56d3d2b929633d80644
|
4
|
+
data.tar.gz: b4eb6f363d662aa82a6390ecb860a41c84401925
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58bfa89eaf1764f2d6964457aa5be9a56366e31a60ab36af5e84f85080e9574cfc5fe76f2348bf55c980e47806535bea36d317ddaa010b788a1d41c8f30bbb9c
|
7
|
+
data.tar.gz: 683e472b2e88c3afc76b56f1e3f7085343a810ba911a78b4eaaa4570df8b4d05076d859d09af9732f1dfcca00cc66c0a9c54571d8290fb2d15d922c3a157a207
|
data/CHANGES.txt
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
1.0.12
|
2
|
+
- Fix bug where specifying the wt property as a string, would add the supplied value to the default ('ruby') rather than overriding it.
|
3
|
+
|
1
4
|
1.0.11
|
2
5
|
- add RSolr.solr_escape method and add deprecation messages to RSolr.escape (ndushay)
|
3
6
|
- use stdlib URI.escape methods instead of homegrown in RSolr::URI (ndushay)
|
data/lib/rsolr/client.rb
CHANGED
@@ -240,7 +240,7 @@ class RSolr::Client
|
|
240
240
|
opts[:proxy] = proxy unless proxy.nil?
|
241
241
|
opts[:method] ||= :get
|
242
242
|
raise "The :data option can only be used if :method => :post" if opts[:method] != :post and opts[:data]
|
243
|
-
opts[:params] =
|
243
|
+
opts[:params] = params_with_wt(opts[:params])
|
244
244
|
query = RSolr::Uri.params_to_solr(opts[:params]) unless opts[:params].empty?
|
245
245
|
opts[:query] = query
|
246
246
|
if opts[:data].is_a? Hash
|
@@ -252,7 +252,13 @@ class RSolr::Client
|
|
252
252
|
opts[:uri] = base_uri.merge(path.to_s + (query ? "?#{query}" : "")) if base_uri
|
253
253
|
opts
|
254
254
|
end
|
255
|
-
|
255
|
+
|
256
|
+
def params_with_wt(params)
|
257
|
+
return { wt: default_wt } if params.nil?
|
258
|
+
return params if params.key?(:wt) || params.key?('wt')
|
259
|
+
{ wt: default_wt }.merge(params)
|
260
|
+
end
|
261
|
+
|
256
262
|
def build_paginated_request page, per_page, path, opts
|
257
263
|
per_page = per_page.to_s.to_i
|
258
264
|
page = page.to_s.to_i-1
|
data/lib/rsolr/version.rb
CHANGED
data/spec/api/client_spec.rb
CHANGED
@@ -258,34 +258,42 @@ describe "RSolr::Client" do
|
|
258
258
|
|
259
259
|
context "build_request" do
|
260
260
|
include ClientHelper
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
261
|
+
let(:data) { 'data' }
|
262
|
+
let(:params) { { q: 'test', fq: [0,1] } }
|
263
|
+
let(:options) { { method: :post, params: params, data: data, headers: {} } }
|
264
|
+
subject { client.build_request('select', options) }
|
265
|
+
|
266
|
+
context "when params are symbols" do
|
267
|
+
it 'should return a request context array' do
|
268
|
+
[/fq=0/, /fq=1/, /q=test/, /wt=ruby/].each do |pattern|
|
269
|
+
expect(subject[:query]).to match pattern
|
270
|
+
end
|
271
|
+
expect(subject[:data]).to eq("data")
|
272
|
+
expect(subject[:headers]).to eq({})
|
270
273
|
end
|
271
|
-
expect(result[:data]).to eq("data")
|
272
|
-
expect(result[:headers]).to eq({})
|
273
274
|
end
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
:
|
279
|
-
:
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
275
|
+
|
276
|
+
context "when params are strings" do
|
277
|
+
let(:params) { { 'q' => 'test', 'wt' => 'json' } }
|
278
|
+
it 'should return a request context array' do
|
279
|
+
expect(subject[:query]).to eq 'q=test&wt=json'
|
280
|
+
expect(subject[:data]).to eq("data")
|
281
|
+
expect(subject[:headers]).to eq({})
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
context "when a Hash is passed in as data" do
|
286
|
+
let(:data) { { q: 'test', fq: [0,1] } }
|
287
|
+
let(:options) { { method: :post, data: data, headers: {} } }
|
288
|
+
|
289
|
+
it "sets the Content-Type header to application/x-www-form-urlencoded; charset=UTF-8" do
|
290
|
+
expect(subject[:query]).to eq("wt=ruby")
|
291
|
+
[/fq=0/, /fq=1/, /q=test/].each do |pattern|
|
292
|
+
expect(subject[:data]).to match pattern
|
293
|
+
end
|
294
|
+
expect(subject[:data]).not_to match /wt=ruby/
|
295
|
+
expect(subject[:headers]).to eq({"Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8"})
|
284
296
|
end
|
285
|
-
expect(result[:data]).not_to match /wt=ruby/
|
286
|
-
expect(result[:headers]).to eq({"Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8"})
|
287
297
|
end
|
288
|
-
|
289
298
|
end
|
290
|
-
|
291
299
|
end
|
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.0.
|
4
|
+
version: 1.0.12
|
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: 2015-
|
32
|
+
date: 2015-03-06 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: builder
|
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
version: '0'
|
173
173
|
requirements: []
|
174
174
|
rubyforge_project: rsolr
|
175
|
-
rubygems_version: 2.4.
|
175
|
+
rubygems_version: 2.4.5
|
176
176
|
signing_key:
|
177
177
|
specification_version: 4
|
178
178
|
summary: A Ruby client for Apache Solr
|