Sha256: fef76ba52ec4464cd37b04bf09b14c38096aa5fbd3abdcb32bcf10183f7432c2
Contents?: true
Size: 1.59 KB
Versions: 2
Compression:
Stored size: 1.59 KB
Contents
require 'spec_helper' module OpenStax module Api describe ApiUser do let(:user) { DummyUser.create } let(:application) { double('Doorkeeper::Application') } let(:doorkeeper_token) { double('Doorkeeper::AccessToken') } let(:non_doorkeeper_user_proc) { lambda { user } } context 'human user' do let(:api_user) { ApiUser.new(nil, non_doorkeeper_user_proc) } it 'has a human_user but no application' do expect(api_user.application).to be_nil expect(api_user.human_user).to eq(user) end end context 'application with human user' do let(:api_user) { ApiUser.new(doorkeeper_token, non_doorkeeper_user_proc) } it 'has a human_user and an application' do allow(doorkeeper_token).to receive(:application).and_return(application) allow(doorkeeper_token).to receive(:resource_owner_id).and_return(user.id) expect(api_user.application).to eq(application) expect(api_user.human_user).to eq(user) end end context 'application only' do let(:api_user) { ApiUser.new(doorkeeper_token, non_doorkeeper_user_proc) } it 'has an application but no human_user' do allow(doorkeeper_token).to receive(:application).and_return(application) allow(doorkeeper_token).to receive(:resource_owner_id).and_return(nil) expect(api_user.application).to eq(application) expect(api_user.human_user).to be_nil end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openstax_api-2.5.1 | spec/models/openstax/api/api_user_spec.rb |
openstax_api-2.5.0 | spec/models/openstax/api/api_user_spec.rb |