adding aliasing of actions

This commit is contained in:
Ryan Bates
2009-11-16 14:58:00 -08:00
parent 6c89c32059
commit 0b8b51b4fc
2 changed files with 38 additions and 11 deletions

View File

@@ -2,6 +2,8 @@ require File.dirname(__FILE__) + '/../spec_helper'
class Ability
include CanCan::Ability
alias_action :update, :destroy, :to => :modify
can :read, :all
can :read, Symbol do |sym|
sym
@@ -12,6 +14,9 @@ class Ability
can :manage, Array do |action, object|
[action, object]
end
can :modify, :all do |object_class, object|
:modify_called
end
end
class AdminAbility
@@ -52,6 +57,11 @@ describe Ability do
@ability.can?(:stuff, [1, 2]).should == [:stuff, [1, 2]]
@ability.can?(:stuff, Array).should == [:stuff, nil]
end
it "should alias update or destroy actions to modify action" do
@ability.can?(:update, 123).should == :modify_called
@ability.can?(:destroy, 123).should == :modify_called
end
end
describe AdminAbility do