Sha256: eb6fee16da0bafbde25dce84ed955ab39c98a7da4919f2d040a7570e3dde6b40
Contents?: true
Size: 1.75 KB
Versions: 4
Compression:
Stored size: 1.75 KB
Contents
require 'spec_helper' describe OAuthSession do let(:session) { Fabricate :oauth_session } let(:response) { double('response', code: 201, parsed_response: 'some_response') } describe '#initialize' do it 'sets the access_token instance variable' do session = Roqua::CoreApi.oauth_session access_token: 'some_access_token' expect(session.access_token).to eq('some_access_token') end it 'allows to override the core_site variable' do session = Roqua::CoreApi.oauth_session access_token: 'some_access_token', core_site: 'some_core_site' expect(session.core_site).to eq('some_core_site') end it 'defaults the AuthSession core_site CORE_SITE env variable default value' do original_env_core_site = ENV['CORE_SITE'] ENV['CORE_SITE'] = 'some_env_core_site' session = Roqua::CoreApi.oauth_session access_token: 'some_access_token' ENV['CORE_SITE'] = original_env_core_site expect(session.core_site).to eq('some_env_core_site') end end describe '#logout_url' do it 'returns the oauth session destroy url with an escaped redirect_to parameter' do expect(session.logout_url return_to: 'some redirect to') .to eq('http://core.dev/session/destroy?token=some_access_token&return_to=some+redirect+to') end end describe 'headers' do it 'sets the Authorization header' do expect(HTTParty).to receive(:get).with(an_instance_of(String), headers: {"Authorization" => "Bearer some_access_token"}, query: {}, basic_auth: nil, timeout: nil).and_return(response) session.get 'some_path' end end end
Version data entries
4 entries across 4 versions & 1 rubygems