Sha256: 33b7dcd4a21d40837dc85b3f94a4d1c9150cb5b3cb2a7028f8dd0a6cf3ccf25f

Contents?: true

Size: 1.45 KB

Versions: 11

Compression:

Stored size: 1.45 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!
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

module CanTango
  class Ability
    def permit_rules
      can :read, Post
    end
  end
end

describe CanTango::AbilityExecutor 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

11 entries across 11 versions & 2 rubygems

Version Path
cantango-core-0.1.2 spec/cantango/ability/executor/base2.rb
cantango-core-0.1.1 spec/cantango/ability/executor/base2.rb
cantango-core-0.1.0 spec/cantango/ability/executor/base2.rb
cantango-0.9.4.7 spec/cantango/ability_executor_spec.rb
cantango-0.9.4.6 spec/cantango/ability_executor_spec.rb
cantango-0.9.4.5 spec/cantango/ability_executor_spec.rb
cantango-0.9.4.3 spec/cantango/ability_executor_spec.rb
cantango-0.9.4.2 spec/cantango/ability_executor_spec.rb
cantango-0.9.4.1 spec/cantango/ability_executor_spec.rb
cantango-0.9.4 spec/cantango/ability_executor_spec.rb
cantango-0.9.3.2 spec/cantango/ability_executor_spec.rb