Sha256: d8e96ee136beeeedc3d64c788825e284ce41d4c1b5b6e1f85b5336d46e46cb56

Contents?: true

Size: 994 Bytes

Versions: 1

Compression:

Stored size: 994 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 = :no_cache
  config.engine(:permit).set :on
  config.debug!
end

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

  protected

  def calc_rules
    can :read, Article
  end
end

describe CanTango::Engine::Permit do
  context 'cache' do
    before do
      @user = User.new 'kris', 'kris@mail.ru', :roles => [:editor]
      @ability = CanTango::Ability::Base.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

1 entries across 1 versions & 1 rubygems

Version Path
cantango-permits-0.1.1 spec/cantango/engine/permit_cached_spec.rb