Sha256: 680b60ddd5dfd9e66b205b91c1355350585f53f6c3c9ae49282d4508ca82fbd8

Contents?: true

Size: 1.19 KB

Versions: 18

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

require 'cantango/rspec/matchers'
require 'fixtures/models'
require 'cantango/rspec/matchers'

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

  protected

  def permit_rules
    can :read, Article
  end
end

class SimpleUser
  attr_accessor :roles_list

  def initialize
    @roles_list = [:customer]
  end

  def role_groups_list
    []
  end
end

describe CanTango::PermitEngine::Executor::Base do
  let (:user) do
    SimpleUser.new
  end

  let (:ability) do
    @ability ||= CanTango::Ability.new user
  end

  let (:permit) do
    CustomerRolePermit.new ability
  end

  let (:executor) do
    CanTango::PermitEngine::Executor::Base.new permit
  end

  before(:each) do
    CanTango.config.permits.set :on
  end

  describe '#execute!' do
    before:each do
      CanTango.config.permits.set :on
    end

    describe 'should find permit based on #roles_list' do
      specify { lambda{ executor.execute! }.should_not raise_error }
    end

    describe 'should search permit based on #role_groups_list' do
      before do
        user.roles_list.clear
      end
      specify { lambda{ executor.execute! }.should_not raise_error }
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
cantango-0.9.4.7 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.9.4.6 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.9.4.5 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.9.4.3 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.9.4.2 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.9.4.1 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.9.4 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.9.3.2 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.8.9.5 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.8.9.4 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.8.9.3 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.8.9.2 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.8.9.1 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.8.9 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.8.8.1 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.8.8 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.8.7 spec/cantango/permit_engine/executor/base_spec.rb
cantango-0.8.6.2 spec/cantango/permit_engine/executor/base_spec.rb