Sha256: a0ae8c4c7e247b882442ae313f47e159f935e16808a733c48121d993d1f6f55d

Contents?: true

Size: 1002 Bytes

Versions: 7

Compression:

Stored size: 1002 Bytes

Contents

require 'rspec'
require 'cantango'
require 'fixtures/models'
require 'cantango/rspec'

def config_folder
  File.dirname(__FILE__)+ "/../fixtures/config/"
end

CanTango.configure do |config|
  config.clear!
  config.ability.mode = :cache
  config.engine(:permit) do |engine|
    engine.mode = :cache
  end
  config.debug!
end

class UserPermit < CanTango::UserPermit
  def initialize ability
    super
  end

  protected

  def static_rules
    can :read, Article
  end
end

describe CanTango::PermitEngine do
  context 'cache' do
    before do
      @user = User.new 'kris'
    end

    let (:ability) do
      CanTango::CachedAbility.new @user
    end
    subject { CanTango::PermitEngine.new ability }

    describe '#execute!' do
      before do
        subject.execute!
      end

      it 'engine should have rules' do
        subject.send(:rules).should_not be_empty
      end

      it 'engine cache should have rules' do
        subject.cache.empty?.should be_false
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cantango-0.9.4.7 spec/cantango/permit_engine_cached_spec.rb
cantango-0.9.4.6 spec/cantango/permit_engine_cached_spec.rb
cantango-0.9.4.5 spec/cantango/permit_engine_cached_spec.rb
cantango-0.9.4.3 spec/cantango/permit_engine_cached_spec.rb
cantango-0.9.4.2 spec/cantango/permit_engine_cached_spec.rb
cantango-0.9.4.1 spec/cantango/permit_engine_cached_spec.rb
cantango-0.9.4 spec/cantango/permit_engine_cached_spec.rb