Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a problem when http.body is empty #800

Merged
merged 2 commits into from
Jul 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2.11.2 (2017-03-13)
* Fix: [#800](https://github.com/savonrb/savon/pull/800) Fix a problem when http.body is empty

# 2.11.1 (2015-05-27)

* Replace dependency on [uuid](https://rubygems.org/gems/uuid), using SecureRandom.uuid instead.
Expand Down
2 changes: 1 addition & 1 deletion lib/savon/soap_fault.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def to_s

def to_hash
parsed = nori.parse(xml || http.body)
nori.find(parsed, 'Envelope', 'Body')
nori.find(parsed, 'Envelope', 'Body') || {}
end

private
Expand Down
5 changes: 5 additions & 0 deletions spec/savon/soap_fault_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
let(:soap_fault_nc) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault)), nori_no_convert }
let(:soap_fault_nc2) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault12)), nori_no_convert }
let(:another_soap_fault) { Savon::SOAPFault.new new_response(:body => Fixture.response(:another_soap_fault)), nori }
let(:soap_fault_no_body) { Savon::SOAPFault.new new_response(:body => {}), nori }
let(:no_fault) { Savon::SOAPFault.new new_response, nori }

let(:nori) { Nori.new(:strip_namespaces => true, :convert_tags_to => lambda { |tag| tag.snakecase.to_sym }) }
Expand Down Expand Up @@ -119,6 +120,10 @@

expect(soap_fault_nc2.to_hash).to eq(expected)
end

it "returns empty hash" do
expect(soap_fault_no_body.to_hash).to eq({})
end
end

def new_response(options = {})
Expand Down