Sha256: 88c36d015ca13c6cedec74e23b5249cbd88ec8e4b7edc7a69025bc2ff86314a6

Contents?: true

Size: 810 Bytes

Versions: 9

Compression:

Stored size: 810 Bytes

Contents

require 'spec_helper'
require 'fixtures/models'

class MyExecutor < CanTango::Ability::Executor::Base
  attr_reader :ability

  def initialize ability
    super
  end

  def valid?
    true
  end

  def cache_key
    :my_exec
  end

  def calculate_rules
    ability.calculate_rules
  end
end

module CanTango::Ability
  class Base
    def calculate_rules
      can :edit, Project
    end
  end
end

describe CanTango::Ability::Executor::Base do
  context 'Custom executor inheriting from Base' do
    before do
      @user = User.new 'kris'
      @ability = CanTango::Ability::Base.new @user
    end

    subject { MyExecutor.new @ability }

    describe '#execute!' do
      before do
        subject.execute!
      end

      specify { subject.ability.send(:rules).should_not be_empty }
    end
  end
end


Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cantango-core-0.1.9.3 spec/cantango/ability/executor/custom_spec.rb
cantango-core-0.1.9.2 spec/cantango/ability/executor/custom_spec.rb
cantango-core-0.1.9.1 spec/cantango/ability/executor/custom_spec.rb
cantango-core-0.1.9 spec/cantango/ability/executor/custom_spec.rb
cantango-core-0.1.8 spec/cantango/ability/executor/custom_spec.rb
cantango-core-0.1.7 spec/cantango/ability/executor/custom_spec.rb
cantango-core-0.1.6 spec/cantango/ability/executor/custom_spec.rb
cantango-core-0.1.5 spec/cantango/ability/executor/custom_spec.rb
cantango-core-0.1.4 spec/cantango/ability/executor/custom_spec.rb