1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00

Fix bug where default_options are unexpectedly modified

This commit is contained in:
Stephan Kaag 2014-07-09 14:04:32 +02:00
parent a320dfbf6e
commit 432b2b29da
2 changed files with 8 additions and 1 deletions

View file

@ -515,7 +515,7 @@ module HTTParty
private
def perform_request(http_method, path, options, &block) #:nodoc:
options = default_options.merge(options)
options = ModuleInheritableAttributes.hash_deep_dup(default_options).merge(options)
process_headers(options)
process_cookies(options)
Request.new(http_method, path, options).perform(&block)

View file

@ -186,6 +186,13 @@ describe HTTParty do
@klass.get('', cookies: {type: 'snickerdoodle'})
end
it 'doesnt modify default_options' do
@klass.headers.should == {}
expect_headers('cookie' => 'type=snickerdoodle')
@klass.get('', cookies: {type: 'snickerdoodle'})
@klass.default_options[:headers].should == {}
end
it 'adds optional cookies to the optional headers' do
expect_headers(baz: 'spax', 'cookie' => 'type=snickerdoodle')
@klass.get('', cookies: {type: 'snickerdoodle'}, headers: {baz: 'spax'})