Sha256: fa1a7a3bafbf2df117173d8a922026dc3cc609b8fdeda50e7a2507e378e24054

Contents?: true

Size: 1.31 KB

Versions: 21

Compression:

Stored size: 1.31 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
    grant.application.should == client
    grant.resource_owner_id  == resource_owner.id
  end

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

  def access_grant_should_not_exist
    Doorkeeper::AccessGrant.all.should be_empty
  end

  def access_token_should_not_exist
    Doorkeeper::AccessToken.all.should be_empty
  end

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

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

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

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
doorkeeper-1.0.0.rc2 spec/support/helpers/model_helper.rb
doorkeeper-1.0.0.rc1 spec/support/helpers/model_helper.rb
doorkeeper-0.7.4 spec/support/helpers/model_helper.rb
doorkeeper-0.7.3 spec/support/helpers/model_helper.rb
doorkeeper-0.7.2 spec/support/helpers/model_helper.rb
doorkeeper-0.7.1 spec/support/helpers/model_helper.rb
doorkeeper-0.7.0 spec/support/helpers/model_helper.rb
doorkeeper-0.6.7 spec/support/helpers/model_helper.rb
doorkeeper-0.6.6 spec/support/helpers/model_helper.rb
doorkeeper-0.6.5 spec/support/helpers/model_helper.rb
doorkeeper-0.6.4 spec/support/helpers/model_helper.rb
doorkeeper-0.6.3 spec/support/helpers/model_helper.rb
doorkeeper-0.6.2 spec/support/helpers/model_helper.rb
doorkeeper-0.6.1 spec/support/helpers/model_helper.rb
doorkeeper-0.6.0 spec/support/helpers/model_helper.rb
doorkeeper-0.6.0.rc1 spec/support/helpers/model_helper.rb
doorkeeper-0.5.0 spec/support/helpers/model_helper.rb
doorkeeper-0.5.0.rc1 spec/support/helpers/model_helper.rb
doorkeeper-0.4.2 spec/support/helpers/model_helper.rb
doorkeeper-0.4.1 spec/support/helpers/model_helper.rb