flexirest 1.8.6 → 1.8.7
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 +4 -4
- data/CHANGELOG.md +7 -1
- data/docs/faraday-configuration.md +1 -1
- data/lib/flexirest/connection.rb +2 -2
- data/lib/flexirest/request.rb +8 -0
- data/lib/flexirest/version.rb +1 -1
- data/spec/lib/request_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fa38d8d7f9ee0f19744e46cfa7a3d0b22eb9d149dce1f5b025beb0f1bbbc6f1
|
4
|
+
data.tar.gz: b2ae4157a3f0fdb754d0a5e1599051be5658a6b342fd9b3d588b4d79b7ed312a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ada072dd254ce8818178de8dab0f72a676e47c0c39e3bc2419b33c3c81ba64e2e9a428bedc42ddcd95d785a2ae3fcafdcecd52fe4f6935e4dd6e0fdc31d7c83
|
7
|
+
data.tar.gz: eb67f39a6697f1e0e48ae8a11037c275f631334d59df36b243e2d5ae2a20e798c8fd614d4a1bb69a561f84db2452af2b6bae417df903b0c0a99b264d9a0555df
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.8.7
|
4
|
+
|
5
|
+
Fix:
|
6
|
+
|
7
|
+
- URL parameters should be automatically required or you end up requesting incorrect URLs (thanks to Marko Kind, @m-kind for the issue).
|
8
|
+
|
3
9
|
## 1.8.6
|
4
10
|
|
5
11
|
Fix:
|
6
12
|
|
7
|
-
- Correct HTTP status code for too many requests (thanks to Tomohiko Mimura, @mito5525
|
13
|
+
- Correct HTTP status code for too many requests (thanks to Tomohiko Mimura, @mito5525 for spotting this).
|
8
14
|
|
9
15
|
## 1.8.5
|
10
16
|
|
@@ -10,7 +10,7 @@ Flexirest::Base.adapter = :patron
|
|
10
10
|
|
11
11
|
In versions before 1.2.0 the adapter was hardcoded to `:patron`, so if you want to ensure it still uses Patron, you should set this setting.
|
12
12
|
|
13
|
-
If you want more control you can pass a **complete** configuration block ("complete" means that the block does not _override_ [the default configuration](https://github.com/flexirest/flexirest/blob/
|
13
|
+
If you want more control you can pass a **complete** configuration block ("complete" means that the block does not _override_ [the default configuration](https://github.com/flexirest/flexirest/blob/master/lib/flexirest/configuration.rb#L292), but rather _replaces_ it).
|
14
14
|
|
15
15
|
For available configuration variables look into the [Faraday documentation](https://github.com/lostisland/faraday).
|
16
16
|
|
data/lib/flexirest/connection.rb
CHANGED
@@ -26,14 +26,14 @@ module Flexirest
|
|
26
26
|
block.call
|
27
27
|
rescue Faraday::Error::TimeoutError
|
28
28
|
raise Flexirest::TimeoutException.new("Timed out getting #{full_url(path)}")
|
29
|
-
rescue Faraday::
|
29
|
+
rescue Faraday::ConnectionFailed => e1
|
30
30
|
if e1.respond_to?(:cause) && e1.cause.is_a?(Net::OpenTimeout)
|
31
31
|
raise Flexirest::TimeoutException.new("Timed out getting #{full_url(path)}")
|
32
32
|
end
|
33
33
|
begin
|
34
34
|
reconnect
|
35
35
|
block.call
|
36
|
-
rescue Faraday::
|
36
|
+
rescue Faraday::ConnectionFailed => e2
|
37
37
|
if e2.respond_to?(:cause) && e2.cause.is_a?(Net::OpenTimeout)
|
38
38
|
raise Flexirest::TimeoutException.new("Timed out getting #{full_url(path)}")
|
39
39
|
end
|
data/lib/flexirest/request.rb
CHANGED
@@ -353,6 +353,7 @@ module Flexirest
|
|
353
353
|
end
|
354
354
|
|
355
355
|
def prepare_url
|
356
|
+
missing = []
|
356
357
|
if @forced_url && @forced_url.present?
|
357
358
|
@url = @forced_url
|
358
359
|
else
|
@@ -368,9 +369,16 @@ module Flexirest
|
|
368
369
|
# it's possible the URL path variable may not be part of the request, in that case, try to resolve it from the object attributes
|
369
370
|
target = @object._attributes[token.to_sym] || "" if target == ""
|
370
371
|
end
|
372
|
+
if target.to_s.blank?
|
373
|
+
missing << token
|
374
|
+
end
|
371
375
|
@url.gsub!(":#{token}", URI.escape(target.to_s).gsub("/", "%2F").gsub("+", "%2B"))
|
372
376
|
end
|
373
377
|
end
|
378
|
+
|
379
|
+
if missing.present?
|
380
|
+
raise Flexirest::MissingParametersException.new("The following parameters weren't specifed: #{missing.join(", ")}")
|
381
|
+
end
|
374
382
|
end
|
375
383
|
|
376
384
|
def append_get_parameters
|
data/lib/flexirest/version.rb
CHANGED
data/spec/lib/request_spec.rb
CHANGED
@@ -37,6 +37,7 @@ describe Flexirest::Request do
|
|
37
37
|
put :headers_default, "/headers_default"
|
38
38
|
put :headers_json, "/headers_json", request_body_type: :json
|
39
39
|
get :find, "/:id", required: [:id]
|
40
|
+
get :find_cat, "/:id/cat"
|
40
41
|
get :change, "/change"
|
41
42
|
get :plain, "/plain/:id", plain: true
|
42
43
|
post :create, "/create", rubify_names: true
|
@@ -288,6 +289,16 @@ describe Flexirest::Request do
|
|
288
289
|
expect{ExampleClient.requires name: nil, age: nil}.to raise_error(Flexirest::MissingParametersException)
|
289
290
|
end
|
290
291
|
|
292
|
+
it "should ensure any URL parameters are implicitly required and error if not specified" do
|
293
|
+
expect_any_instance_of(Flexirest::Connection).to_not receive(:get)
|
294
|
+
expect{ExampleClient.find_cat}.to raise_error(Flexirest::MissingParametersException)
|
295
|
+
end
|
296
|
+
|
297
|
+
it "should ensure any URL parameters are implicitly required and make the request if specified" do
|
298
|
+
expect_any_instance_of(Flexirest::Connection).to receive(:get).and_return(::FaradayResponseMock.new(OpenStruct.new(body:'{"result":true}', response_headers:{})))
|
299
|
+
expect{ExampleClient.find_cat(1)}.to_not raise_error
|
300
|
+
end
|
301
|
+
|
291
302
|
it "should makes the request if all required parameters are specified" do
|
292
303
|
expect_any_instance_of(Flexirest::Connection).to receive(:get).and_return(::FaradayResponseMock.new(OpenStruct.new(body:'{"result":true}', response_headers:{})))
|
293
304
|
expect{ExampleClient.requires name: "John", age: 21}.not_to raise_error
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexirest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jeffries
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|