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

Setting basic_auth on Base doesn't get inherited #276

Closed
coreyward opened this issue Mar 4, 2014 · 5 comments
Closed

Setting basic_auth on Base doesn't get inherited #276

coreyward opened this issue Mar 4, 2014 · 5 comments

Comments

@coreyward
Copy link

Similar to #83. Setting basic_auth in a Base class and inheriting from it in subclasses does not work. Issue exists in Closeio library:

# as expected:
Closeio::Base.default_options
 => {:base_uri=>"https://app.close.io/api/v1", :basic_auth=>{:username=>"foo", :password=>""}, :headers=>{"Content-Type"=>"application/json"}, :parser=>HTTParty::Parser, :format=>:json} 

# unexpected, as described above:
Closeio::Lead.default_options
 => {:base_uri=>"https://app.close.io/api/v1", :basic_auth=>{:username=>nil, :password=>""}, :headers=>{"Content-Type"=>"application/json"}, :parser=>HTTParty::Parser, :format=>:json} 

Using v0.13.0.

@rusikf
Copy link

rusikf commented Dec 18, 2014

@coreyward , can you give full steps for reproduce it ? ( Write here full example, which doesn't work )

@coreyward
Copy link
Author

  1. Set basic_auth on Base, e.g. Base.default_options.merge! basic_auth: { ... }.
  2. Subclass it, e.g. class Lead < Base
  3. Inspect default_options on subclass, e.g. Lead.default_options.

The default options should follow, but do not.

@rusikf
Copy link

rusikf commented Jan 5, 2015

@coreyward , I test it, but it works:

require './lib/httparty'
# first example
class Yandex
  include HTTParty
  basic_auth 'rusik', '123'
end

class YandexMoney < Yandex

end  
p Yandex.default_options
p YandexMoney.default_options
p Yandex.default_options == YandexMoney.default_options
# second example
class Google
  include HTTParty
end
Google.default_options.merge! basic_auth: {username: 'john', password: '123'}
class GoogleWallet < Google
end

p Google.default_options
p GoogleWallet.default_options  
p Google.default_options == GoogleWallet.default_options

Output:

/httparty$ pry fun.rb 
{:basic_auth=>{:username=>"rusik", :password=>"123"}}
{:basic_auth=>{:username=>"rusik", :password=>"123"}}
true
{:basic_auth=>{:username=>"john", :password=>"123"}}
{:basic_auth=>{:username=>"john", :password=>"123"}}
true
ruslan@rs3:~/Work/httparty-fun/httparty$ pry fun.rb 
{:basic_auth=>{:username=>"rusik", :password=>"123"}}
{:basic_auth=>{:username=>"rusik", :password=>"123"}}
true
{:basic_auth=>{:username=>"john", :password=>"123"}}
{:basic_auth=>{:username=>"john", :password=>"123"}}
true

@jnunemaker, what you think about it ?

@jnunemaker
Copy link
Owner

I guess closing until we get something repeatable to prove there is an issue.

@coreyward
Copy link
Author

Hmm, I wonder if it isn't a version issue, or perhaps because CloseIO inherits from OpenStruct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants