Sha256: 713612f8210a562ade77b653b22d3c686112c8d5ae823eea26dc98997b99cc29

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

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) do |engine|
    engine.mode = :no_cache
  end
  config.debug!
end

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

  protected

  def calc_rules
    can :read, Article
  end
end

describe CanTango::PermitEngine do
  context 'no-cache' do
    before do
      @user = User.new 'kris', 'kris@mail.ru', :roles => [:editor]
    end

    describe 'Permit engine' do
      let (:ability) do
        CanTango::Ability.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 be empty' do
          subject.cache.empty?.should be_true
        end
      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_spec.rb