mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-07 00:11:11 -04:00
Simplify copying custom_members
to new Env instance
This commit is contained in:
parent
03f373a1fb
commit
441d8ac979
@ -272,10 +272,8 @@ module Faraday
|
||||
# Public
|
||||
def self.from(value)
|
||||
env = super(value)
|
||||
if value.kind_of?(self)
|
||||
value.custom_members.each do |custom_key, custom_value|
|
||||
env[custom_key] = custom_value
|
||||
end
|
||||
if value.respond_to?(:custom_members)
|
||||
env.custom_members.update(value.custom_members)
|
||||
end
|
||||
env
|
||||
end
|
||||
|
@ -70,13 +70,15 @@ class EnvTest < Faraday::TestCase
|
||||
assert_equal 'proxy.com', env.request.proxy.host
|
||||
end
|
||||
|
||||
def test_custom_headers_are_retained
|
||||
def test_custom_members_are_retained
|
||||
env = make_env
|
||||
env[:foo] = "custom 1"
|
||||
env[:bar] = :custom_2
|
||||
env2 = Faraday::Env.from(env)
|
||||
assert_equal "custom 1", env2[:foo]
|
||||
assert_equal :custom_2, env2[:bar]
|
||||
env2[:baz] = "custom 3"
|
||||
assert_nil env[:baz]
|
||||
end
|
||||
|
||||
private
|
||||
|
Loading…
x
Reference in New Issue
Block a user