Sha256: 72a723a5534206fa6ea7e79a76d6c4a7d21ef2da5cea12522f4b9abd0e34b475

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'
require 'fixtures/models'

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

  protected

  def no_cache_rules
    can :edit, Article
    can :delete, Article
  end
end

class CanTango::Ability::Base
  def subject
    candidate
  end

  def user
    subject
  end
end

describe CanTango::Executor::Permit::Base do
  context 'non-cached only' do
    before do
      CanTango.configure.ability.modes.execution.register :no_cache

      @admin    = Admin.new 'kris', 'kris@mail.ru'
      @ability  = CanTango::Ability::Base.new @admin
      @permit   = AdminPermit.new @ability
      @executor = CanTango::Executor::Permit::Base.new @permit
    end

    subject { @executor }

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

    describe 'rules contain only non-cached rules' do
      before do
        subject.execute!
      end
      it 'should have 2 rules' do
        subject.rules.size.should == @ability.rules.size
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-permits-0.1.1 spec/cantango/executor/permit_spec.rb