Sha256: 4f2dd9005fa0e80ff8cb8678b7367faad8962cfe1049f55ddfe97b833fe25ee3

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper_integration'

describe Doorkeeper::AccessGrant do
  subject { FactoryGirl.build(:access_grant) }

  it { should be_valid }

  it_behaves_like "an accessible token"
  it_behaves_like "a revocable token"
  it_behaves_like "an unique token" do
    let(:factory_name) { :access_grant }
  end

  describe "validations" do
    it "is invalid without resource_owner_id" do
      subject.resource_owner_id = nil
      should_not be_valid
    end

    it "is invalid without application_id" do
      subject.application_id = nil
      should_not be_valid
    end

    it "is invalid without token" do
      subject.save
      subject.token = nil
      should_not be_valid
    end

    it "is invalid without expires_in" do
      subject.expires_in = nil
      should_not be_valid
    end
  end

  describe :scopes do
    it "is nil when scopes are not set" do
      subject.scopes = nil
      subject.scopes.should be_nil
    end

    describe "returns an array of scopes" do
      subject { FactoryGirl.create(:access_grant, :scopes => "public write").scopes }

      it { should be_kind_of(Array) }
      its(:count) { should == 2 }
      it { should include(:public, :write) }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
doorkeeper-0.3.4 spec/models/doorkeeper/access_grant_spec.rb
doorkeeper-0.3.3 spec/models/doorkeeper/access_grant_spec.rb
doorkeeper-0.3.2 spec/models/doorkeeper/access_grant_spec.rb