1
0
Fork 0
mirror of https://github.com/omniauth/omniauth.git synced 2022-11-09 12:31:49 -05:00

Remove duplicative eval of credentials and extra

This commit is contained in:
zino 2020-04-25 15:45:13 -05:00
parent fce9e23dd4
commit 1cd79a1769
2 changed files with 9 additions and 3 deletions

View file

@ -347,8 +347,8 @@ module OmniAuth
def auth_hash def auth_hash
hash = AuthHash.new(:provider => name, :uid => uid) hash = AuthHash.new(:provider => name, :uid => uid)
hash.info = info unless skip_info? hash.info = info unless skip_info?
hash.credentials = credentials if credentials (credentials_data = credentials) && hash.credentials = credentials_data
hash.extra = extra if extra (extra_data = extra) && hash.extra = extra_data
hash hash
end end

View file

@ -173,19 +173,25 @@ describe OmniAuth::Strategy do
end end
let(:instance) { subject.new(app) } let(:instance) { subject.new(app) }
it 'calls through to uid and info' do it 'calls through to uid, info, credentials, and extra' do
expect(instance).to receive(:uid) expect(instance).to receive(:uid)
expect(instance).to receive(:info) expect(instance).to receive(:info)
expect(instance).to receive(:credentials).and_return(expires: true).once
expect(instance).to receive(:extra).and_return(something: 'else').once
instance.auth_hash instance.auth_hash
end end
it 'returns an AuthHash' do it 'returns an AuthHash' do
allow(instance).to receive(:uid).and_return('123') allow(instance).to receive(:uid).and_return('123')
allow(instance).to receive(:info).and_return(:name => 'Hal Awesome') allow(instance).to receive(:info).and_return(:name => 'Hal Awesome')
allow(instance).to receive(:credentials).and_return(expires: true)
allow(instance).to receive(:extra).and_return(something: 'else')
hash = instance.auth_hash hash = instance.auth_hash
expect(hash).to be_kind_of(OmniAuth::AuthHash) expect(hash).to be_kind_of(OmniAuth::AuthHash)
expect(hash.uid).to eq('123') expect(hash.uid).to eq('123')
expect(hash.info.name).to eq('Hal Awesome') expect(hash.info.name).to eq('Hal Awesome')
expect(hash.credentials.expires).to eq(true)
expect(hash.extra.something).to eq('else')
end end
end end