Sha256: c44b08f8d448a453a956abe44eb372332201d0c204b1ec9772eabfefa5bc94e9

Contents?: true

Size: 1.66 KB

Versions: 36

Compression:

Stored size: 1.66 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../simple_spec_helper')

class TestAbility
  def initialize(*args)
  end
end

describe Lolita::Extensions::Authorization::Proxy do 
  let(:klass){ Lolita::Extensions::Authorization::Proxy }
  let(:proxy){ klass.new(Object.new,{}) }
  around(:each) do |example|
    Lolita.ability_class = TestAbility
    example.run
    Lolita.ability_class = nil
  end
  
  it "should create new proxy" do
    expect do
      klass.new(Object.new,{})
    end.not_to raise_error
  end

  it "should have #can?" do
    proxy.respond_to?(:can?).should be_true
  end
  
  it "should have #cannot?" do
    proxy.respond_to?(:cannot?).should be_true
  end

  it "should have #authorize!" do
    proxy.respond_to?(:authorize!).should be_true
  end

  it "should have #current_ability" do
    proxy.respond_to?(:current_ability).should be_true
  end

  describe 'Connecting adapter' do
    context 'default adapter' do
      it "should create when authorization is not specified or is 'Default'" do
        proxy.adapter.should be_a(Lolita::Extensions::Authorization::DefaultAdapter)
        Lolita.authorization = 'Default'
        proxy.adapter.should be_a(Lolita::Extensions::Authorization::DefaultAdapter)
      end
    end
    context 'devise adapter' do
      let(:proxy){ 
        mock_class = Object.new
        mock_class.class_eval{include Lolita::Extensions}
        klass.new(mock_class,{}) 
      }
      it "should create when Lolita.authentication is specified" do
        Lolita.authorization = 'CanCan'
        proxy.adapter.should be_a(Lolita::Extensions::Authorization::CanCanAdapter)
        Lolita.authorization = nil
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
lolita-4.0.11 spec/extensions/authorization/proxy_spec.rb
lolita-4.2.0 spec/extensions/authorization/proxy_spec.rb
lolita-4.0.10 spec/extensions/authorization/proxy_spec.rb
lolita-4.0.9 spec/extensions/authorization/proxy_spec.rb
lolita-4.0.8 spec/extensions/authorization/proxy_spec.rb
lolita-4.0.7 spec/extensions/authorization/proxy_spec.rb
lolita-4.0.6 spec/extensions/authorization/proxy_spec.rb
lolita-4.0.5 spec/extensions/authorization/proxy_spec.rb
lolita-4.0.4 spec/extensions/authorization/proxy_spec.rb
lolita-4.0.3 spec/extensions/authorization/proxy_spec.rb
lolita-4.0.2 spec/extensions/authorization/proxy_spec.rb
lolita-4.0.1 spec/extensions/authorization/proxy_spec.rb
lolita-4.0.0 spec/extensions/authorization/proxy_spec.rb
lolita-3.4.3 spec/extensions/authorization/proxy_spec.rb
lolita-3.4.2 spec/extensions/authorization/proxy_spec.rb
lolita-3.4.1 spec/extensions/authorization/proxy_spec.rb
lolita-3.4.0 spec/extensions/authorization/proxy_spec.rb
lolita-3.3.9 spec/extensions/authorization/proxy_spec.rb
lolita-3.3.8 spec/extensions/authorization/proxy_spec.rb
lolita-3.3.7 spec/extensions/authorization/proxy_spec.rb