delsolr 0.1.3 → 0.1.4
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.
- data/lib/delsolr.rb +5 -6
- data/test/test_client.rb +13 -0
- metadata +3 -3
data/lib/delsolr.rb
CHANGED
@@ -166,12 +166,7 @@ module DelSolr
|
|
166
166
|
end
|
167
167
|
|
168
168
|
if body.blank? # cache miss (or wasn't enabled)
|
169
|
-
|
170
|
-
header, body = connection.get(configuration.path + query_builder.request_string)
|
171
|
-
rescue Timeout::Error
|
172
|
-
# If we timed out, just return nil and let the client decide what to do
|
173
|
-
return nil
|
174
|
-
end
|
169
|
+
header, body = connection.get(configuration.path + query_builder.request_string)
|
175
170
|
|
176
171
|
# We get UTF-8 from Solr back, make sure the string knows about it
|
177
172
|
# when running on Ruby >= 1.9
|
@@ -196,6 +191,10 @@ module DelSolr
|
|
196
191
|
logger.info "#{from_cache ? 'C' : 'S'},#{response_stat_string}http://#{configuration.full_path}#{response.request_url}"
|
197
192
|
end
|
198
193
|
response
|
194
|
+
# If we error, just return nil and let the client decide what to do
|
195
|
+
rescue StandardError
|
196
|
+
logger.info "http://#{configuration.full_path}#{query_builder.request_string}" if logger && configuration && query_builder
|
197
|
+
return nil
|
199
198
|
end
|
200
199
|
|
201
200
|
# Adds a document to the buffer to be posted to solr (NOTE: does not perform the actual post)
|
data/test/test_client.rb
CHANGED
@@ -176,6 +176,19 @@ class ClientTest < Test::Unit::TestCase
|
|
176
176
|
assert(c.update!(doc))
|
177
177
|
assert_equal(0, c.pending_documents.length)
|
178
178
|
end
|
179
|
+
|
180
|
+
def test_query_returns_nil_when_exception_thrown
|
181
|
+
c = setup_client
|
182
|
+
|
183
|
+
mock_query_builder = DelSolr::Client::QueryBuilder
|
184
|
+
mock_query_builder.stubs(:request_string).returns('/select?some_query') # mock the query builder
|
185
|
+
DelSolr::Client::QueryBuilder.stubs(:new).returns(mock_query_builder)
|
186
|
+
c.connection.expects(:get).raises(StandardError) # mock the connection
|
187
|
+
assert_nothing_raised do
|
188
|
+
r = c.query('standard', :query => '123')
|
189
|
+
assert_nil(r)
|
190
|
+
end
|
191
|
+
end
|
179
192
|
|
180
193
|
def test_query_with_path
|
181
194
|
c = setup_client(:path => '/abcsolr')
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ben VandenBos
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2009-11-02 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|