maremma 2.3 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzgwMGIxMjdiNDg1MWRjNmU0ZWQxMGRjZDBmNWRjNGQ4YmZlMDllNw==
4
+ ZjQ3OGFkNDYzZDQ2NGE1NzFiOWY0NWViZDYxNzRkMjViYTMxYTFlNA==
5
5
  data.tar.gz: !binary |-
6
- OWUyOTYwYWUyMTllNzkzNGZiOWU0YjM1MzE1NmVjMTY3YjZkNzhlNg==
6
+ YTAyZGI5NzNhMWJjYmU0YTA3ZGMzYzQyZGEwYzFlMzkxZGY2MWY2OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTE1MDU3YTRmN2Y3MWQ0Mzg4NzA5MWJiZWJiNDBhNTRlMWRlY2Y5YWM4ODQw
10
- YzFiNGJmYTcwNWRiOGI4ZjkzZTgxYThkMjk4OWZiZWYyNDE1MDFhOTAxNzVi
11
- OTk1YTJiOWYyOTNjOWFlNDA3OGEyN2ZiNDk5NTFhYTMwMGZmNTE=
9
+ NWZiY2Y0NGQzNTViY2JkMDE1N2I1MjA2NjVlOTg1NDI4MTZhN2YwODE0ZWNh
10
+ ODUxZDg5NDY2OWNlYjAxOTI3ZWU4MTBkNDUyYTEyMjg3NDFiN2MwM2NlOThm
11
+ ZjcyZjc0NzA2MTU0NmZmYjc2YjE2MGRmMDU1M2YxMjJmYzlmMDQ=
12
12
  data.tar.gz: !binary |-
13
- NDI4NTliODQ4NzE5ZWIyYWU1ZWIzN2NjZDAyYmQwMzRmNjkyOGQ3YmMwMGU2
14
- M2IxNjI4ZDkxZWMwMzVjMzMzNjVkZGZiN2EwNTA3N2VhNDA2ZGUyYzkyNTZi
15
- NmNlZjMzNmY4MmI0MmJlNTg2OTU2MDNkZGI0MTY4MGZmNWJmZjU=
13
+ ZDRiM2E0M2ZjYjBmZTNlYjljODMzNDlkYjZmMjE1NzY1ZDkyMzFjYjhkODYx
14
+ ZDY0NjViNTE4NmQzNTE0NDI3ZGU5MDkzNzA5ZGM5ZDQ3YjhmMzJlZGQ1NzZh
15
+ ZWIwZmQxMGQ3NjRlMzJkMDJhYzY5NjE2Y2QxOGZmMWUxYjliMzA=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v.2.3.1 (September 2, 2016)
2
+
3
+ [maremma 2.3.1](https://github.com/datacite/maremma/releases/tag/v.2.3.1) was released on September 2, 2016:
4
+
5
+ * handle `Faraday::ConnectionFailed` errors with an appropriate error message
6
+
1
7
  ## v.2.3 (August 16, 2016)
2
8
 
3
9
  [maremma 2.3](https://github.com/datacite/maremma/releases/tag/v.2.3) was released on August 16, 2016:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maremma (2.3)
4
+ maremma (2.3.1)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  builder (~> 3.2, >= 3.2.2)
7
7
  excon (~> 0.45.0)
data/lib/maremma.rb CHANGED
@@ -109,7 +109,9 @@ module Maremma
109
109
  def self.rescue_faraday_error(error)
110
110
  if error.is_a?(Faraday::ResourceNotFound)
111
111
  { 'errors' => [{ 'status' => 404, 'title' => "Not found" }] }
112
- elsif error.is_a?(Faraday::TimeoutError) || error.is_a?(Faraday::ConnectionFailed) || (error.try(:response) && error.response[:status] == 408)
112
+ elsif error.is_a?(Faraday::ConnectionFailed)
113
+ { 'errors' => [{ 'status' => "403", 'title' => parse_error_response(error.message) }] }
114
+ elsif error.is_a?(Faraday::TimeoutError) || (error.try(:response) && error.response[:status] == 408)
113
115
  { 'errors' => [{ 'status' => 408, 'title' =>"Request timeout" }] }
114
116
  else
115
117
  { 'errors' => [{ 'status' => 400, 'title' => parse_error_response(error.message) }] }
@@ -1,3 +1,3 @@
1
1
  module Maremma
2
- VERSION = "2.3"
2
+ VERSION = "2.3.1"
3
3
  end
data/spec/maremma_spec.rb CHANGED
@@ -140,6 +140,35 @@ describe Maremma do
140
140
  end
141
141
  end
142
142
 
143
+ context "connection failed" do
144
+ it "get json" do
145
+ stub = stub_request(:get, url).to_raise(Faraday::ConnectionFailed.new("Connection refused - connect(2)"))
146
+ response = subject.get(url)
147
+ expect(response).to eq("errors"=>[{"status"=>"403", "title"=>"Connection refused - connect(2)"}])
148
+ expect(stub).to have_been_requested
149
+ end
150
+
151
+ it "get xml" do
152
+ stub = stub_request(:get, url).to_raise(Faraday::ConnectionFailed.new("Connection refused - connect(2)"))
153
+ response = subject.get(url, content_type: 'xml')
154
+ expect(response).to eq("errors"=>[{"status"=>"403", "title"=>"Connection refused - connect(2)"}])
155
+ expect(stub).to have_been_requested
156
+ end
157
+
158
+ it "get html" do
159
+ stub = stub_request(:get, url).to_raise(Faraday::ConnectionFailed.new("Connection refused - connect(2)"))
160
+ response = subject.get(url, content_type: 'html')
161
+ expect(response).to eq("errors"=>[{"status"=>"403", "title"=>"Connection refused - connect(2)"}])
162
+ expect(stub).to have_been_requested
163
+ end
164
+
165
+ it "post xml" do
166
+ stub = stub_request(:post, url).with(:body => post_data.to_xml).to_raise(Faraday::ConnectionFailed.new("Connection refused - connect(2)"))
167
+ subject.post(url, content_type: 'xml', data: post_data.to_xml) { |response| expect(response).to be_nil }
168
+ expect(stub).to have_been_requested
169
+ end
170
+ end
171
+
143
172
  context "request timeout internal" do
144
173
  it "get json" do
145
174
  stub = stub_request(:get, url).to_timeout
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maremma
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.3'
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-16 00:00:00.000000000 Z
11
+ date: 2016-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday