Merge pull request #378 from janko-m/fix-parallel-parsing

Fix response not changing with parallel requests
This commit is contained in:
Mislav Marohnić 2014-05-24 00:41:51 +07:00
commit 4fe046e6ba
2 changed files with 9 additions and 1 deletions

View File

@ -61,8 +61,8 @@ module Faraday
def finish(env)
raise "response already finished" if finished?
@env = Env.from(env)
@on_complete_callbacks.each { |callback| callback.call(env) }
@env = Env.from(env)
return self
end

View File

@ -166,6 +166,14 @@ class ResponseTest < Faraday::TestCase
end
end
def test_body_is_parsed_on_finish
response = Faraday::Response.new
response.on_complete { |env| env[:body] = env[:body].upcase }
response.finish(@env)
assert_equal "YIKES", response.body
end
def test_not_success
assert !@response.success?
end