Sha256: 6940a5edbcafa301521830ab288a587974e1455dd822ca46962cf80412182548

Contents?: true

Size: 1.79 KB

Versions: 14

Compression:

Stored size: 1.79 KB

Contents

shared_context 'valid token', token: :valid do
  let(:token_string) { '1A2B3C4D' }

  let :token do
    double(Doorkeeper::AccessToken,
           accessible?: true, includes_scope?: true, acceptable?: true,
           previous_refresh_token: "", revoke_previous_refresh_token!: true)
  end

  before :each do
    allow(
      Doorkeeper::AccessToken
    ).to receive(:by_token).with(token_string).and_return(token)
  end
end

shared_context 'invalid token', token: :invalid do
  let(:token_string) { '1A2B3C4D' }

  let :token do
    double(Doorkeeper::AccessToken,
           accessible?: false, revoked?: false, expired?: false,
           includes_scope?: false, acceptable?: false,
           previous_refresh_token: "", revoke_previous_refresh_token!: true)
  end

  before :each do
    allow(
      Doorkeeper::AccessToken
    ).to receive(:by_token).with(token_string).and_return(token)
  end
end

shared_context 'authenticated resource owner' do
  before do
    user = double(:resource, id: 1)
    allow(Doorkeeper.configuration).to receive(:authenticate_resource_owner) { proc { user } }
  end
end

shared_context 'not authenticated resource owner' do
  before do
    allow(Doorkeeper.configuration).to receive(:authenticate_resource_owner) { proc { redirect_to '/' } }
  end
end

shared_context 'valid authorization request' do
  let :authorization do
    double(:authorization, valid?: true, authorize: true, success_redirect_uri: 'http://something.com/cb?code=token')
  end

  before do
    allow(controller).to receive(:authorization) { authorization }
  end
end

shared_context 'invalid authorization request' do
  let :authorization do
    double(:authorization, valid?: false, authorize: false, redirect_on_error?: false)
  end

  before do
    allow(controller).to receive(:authorization) { authorization }
  end
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
doorkeeper-mongodb-4.2.0 spec/support/shared/controllers_shared_context.rb
doorkeeper-sequel-1.5.0 spec/support/shared/controllers_shared_context.rb
doorkeeper-4.4.3 spec/support/shared/controllers_shared_context.rb
doorkeeper-5.0.0 spec/support/shared/controllers_shared_context.rb
doorkeeper-4.4.2 spec/support/shared/controllers_shared_context.rb
doorkeeper-4.4.1 spec/support/shared/controllers_shared_context.rb
doorkeeper-5.0.0.rc2 spec/support/shared/controllers_shared_context.rb
doorkeeper-4.4.0 spec/support/shared/controllers_shared_context.rb
doorkeeper-5.0.0.rc1 spec/support/shared/controllers_shared_context.rb
doorkeeper-mongodb-4.1.0 spec/support/shared/controllers_shared_context.rb
doorkeeper-4.3.2 spec/support/shared/controllers_shared_context.rb
doorkeeper-4.3.1 spec/support/shared/controllers_shared_context.rb
doorkeeper-4.3.0 spec/support/shared/controllers_shared_context.rb
doorkeeper-sequel-1.4.0 spec/support/shared/controllers_shared_context.rb