Sha256: 14f142258b8d556e8c5c35841ab8045421244e01170d130c2c88a9ab199eceb9

Contents?: true

Size: 1.4 KB

Versions: 7

Compression:

Stored size: 1.4 KB

Contents

require 'rspec'
require 'cantango'
# require 'simple_roles'
require 'fixtures/models'
require 'cantango/rspec'

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

CanTango.configure do |config|
  config.clear!
  config.permits.enabled_types = [:role]
end
CanTango.debug!

class User
  tango_user
  include_and_extend SimpleRoles
end

class AdminRolePermit < CanTango::RolePermit
  def initialize ability
    super
  end

  protected

  def static_rules
    can :read, Article
  end

  module Cached
    def permit_rules
      can :edit, Article
      can :delete, Article
    end
  end
end

describe CanTango::Permits::Executor do
  context 'non-cached only' do
    before do
      CanTango.configure.ability.mode = :no_cache

      @user = User.new 'admin', 'admin@mail.ru', :role => 'admin'
      @abil = CanTango::AbilityExecutor.new @user
    end

    subject { CanTango::AbilityExecutor.new @user }

    describe 'config no_cache' do
      specify { CanTango.configure.ability.modes.should == [:no_cache] }
    end

    describe 'engines_on?' do
      specify { subject.engines_on?.should be_true }
    end

    its(:cached_rules)      { should be_empty }
    its(:non_cached_rules)  { should_not be_empty }

    describe 'rules contain only non-cached rules' do
      specify { subject.rules.size.should == @abil.non_cached_rules.size }
      specify { subject.rules.size.should == 2 }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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