Sha256: a7f5589029c20dd698c7da70eca44600ca4c175189bfe76199922e1d0c628907

Contents?: true

Size: 1.14 KB

Versions: 36

Compression:

Stored size: 1.14 KB

Contents

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

describe Lolita::Extensions::Authorization::DefaultAdapter do
  let(:klass){ Lolita::Extensions::Authorization::DefaultAdapter }
  let(:adapter){ klass.new(Object.new,{}) }

  it "should create new" do
    expect do
      klass.new(Object.new,{})
    end.not_to raise_error
  end
  
  context "current user" do

    it "can do all" do
      adapter.can?(:read,Object.new).should be_true
    end

    it "cannot do nothing" do
      adapter.cannot?([]).should be_false
    end

    it "should not have current ability" do
      adapter.current_ability.should be_nil
    end
    
    it "should be authorized for all" do
      expect do
        adapter.authorize!
      end.not_to raise_error
    end
  end

  describe 'Integration with proxy' do
    let(:proxy){ Lolita::Extensions::Authorization::Proxy.new(Object.new,{}) }
      it "should have the same method results for adapter and proxy" do
        proxy.adapter = adapter
        %w(can? cannot? current_ability authorize!).each do |name|
          proxy.send(name).should eql(adapter.send(name))
        end
      end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

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