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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d605bb65e2fdbd7e99f9bd1890549408f304016e
4
- data.tar.gz: 02b7f7e889860627575f10e55b6fe73c9c73663c
3
+ metadata.gz: a71555285360893206f2b56d3d2b929633d80644
4
+ data.tar.gz: b4eb6f363d662aa82a6390ecb860a41c84401925
5
5
  SHA512:
6
- metadata.gz: 656df9328215c9dba8d747baa7faff8b47a7b6a0fb5a8a46cb0246a7967ea7ecee78f5f59076396ddd463fd4413f8d54a7efc914df59c64c614a13fe396f1763
7
- data.tar.gz: 8efa618685448b35cc7da82c6ec0576b17838bddc4924fb70ac07529afc2075754f9231697b221c42f0fe418010332ddce050236a4d16d1bf0b994d7855975cb
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] = opts[:params].nil? ? {:wt => default_wt} : {:wt => default_wt}.merge(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
@@ -1,5 +1,5 @@
1
1
  module RSolr
2
- VERSION = "1.0.11"
2
+ VERSION = "1.0.12"
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -258,34 +258,42 @@ describe "RSolr::Client" do
258
258
 
259
259
  context "build_request" do
260
260
  include ClientHelper
261
- it 'should return a request context array' do
262
- result = client.build_request('select',
263
- :method => :post,
264
- :params => {:q=>'test', :fq=>[0,1]},
265
- :data => "data",
266
- :headers => {}
267
- )
268
- [/fq=0/, /fq=1/, /q=test/, /wt=ruby/].each do |pattern|
269
- expect(result[:query]).to match pattern
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
- it "should set the Content-Type header to application/x-www-form-urlencoded; charset=UTF-8 if a hash is passed in to the data arg" do
276
- result = client.build_request('select',
277
- :method => :post,
278
- :data => {:q=>'test', :fq=>[0,1]},
279
- :headers => {}
280
- )
281
- expect(result[:query]).to eq("wt=ruby")
282
- [/fq=0/, /fq=1/, /q=test/].each do |pattern|
283
- expect(result[:data]).to match pattern
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.11
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-02-26 00:00:00.000000000 Z
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.3
175
+ rubygems_version: 2.4.5
176
176
  signing_key:
177
177
  specification_version: 4
178
178
  summary: A Ruby client for Apache Solr