Sha256: 6c93fb1b872bbf191b524a8bd24d1e8d85d81527baa6cf9df1af22f49592c7a1

Contents?: true

Size: 1.33 KB

Versions: 14

Compression:

Stored size: 1.33 KB

Contents

module ModelHelper
  def client_exists(client_attributes = {})
    @client = FactoryGirl.create(:application, client_attributes)
  end

  def create_resource_owner
    @resource_owner = User.create!(name: 'Joe', password: 'sekret')
  end

  def authorization_code_exists(options = {})
    @authorization = FactoryGirl.create(:access_grant, options)
  end

  def access_grant_should_exist_for(client, resource_owner)
    grant = Doorkeeper::AccessGrant.first
    expect(grant.application).to eq(client)
    grant.resource_owner_id  == resource_owner.id
  end

  def access_token_should_exist_for(client, resource_owner)
    grant = Doorkeeper::AccessToken.first
    expect(grant.application).to eq(client)
    grant.resource_owner_id  == resource_owner.id
  end

  def access_grant_should_not_exist
    expect(Doorkeeper::AccessGrant.all).to be_empty
  end

  def access_token_should_not_exist
    expect(Doorkeeper::AccessToken.all).to be_empty
  end

  def access_grant_should_have_scopes(*args)
    grant = Doorkeeper::AccessGrant.first
    expect(grant.scopes).to eq(Doorkeeper::OAuth::Scopes.from_array(args))
  end

  def access_token_should_have_scopes(*args)
    grant = Doorkeeper::AccessToken.first
    expect(grant.scopes).to eq(Doorkeeper::OAuth::Scopes.from_array(args))
  end
end

RSpec.configuration.send :include, ModelHelper, type: :request

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
doorkeeper-1.4.2 spec/support/helpers/model_helper.rb
doorkeeper-2.1.2 spec/support/helpers/model_helper.rb
doorkeeper-2.1.1 spec/support/helpers/model_helper.rb
doorkeeper-2.1.0 spec/support/helpers/model_helper.rb
doorkeeper-2.0.1 spec/support/helpers/model_helper.rb
doorkeeper-1.4.1 spec/support/helpers/model_helper.rb
doorkeeper-2.0.0 spec/support/helpers/model_helper.rb
doorkeeper-2.0.0.rc3 spec/support/helpers/model_helper.rb
doorkeeper-2.0.0.rc2 spec/support/helpers/model_helper.rb
doorkeeper-2.0.0.alpha1 spec/support/helpers/model_helper.rb
doorkeeper-1.4.0 spec/support/helpers/model_helper.rb
doorkeeper-1.3.1 spec/support/helpers/model_helper.rb
doorkeeper-1.3.0 spec/support/helpers/model_helper.rb
doorkeeper-1.2.0 spec/support/helpers/model_helper.rb