return subject passed to authorize! - closes #314

This commit is contained in:
Ryan Bates 2011-03-25 14:24:43 -07:00
parent 5d97cfb236
commit 1ac8099f7a
2 changed files with 5 additions and 2 deletions

View File

@ -201,6 +201,7 @@ module CanCan
message ||= unauthorized_message(action, subject)
raise AccessDenied.new(message, action, subject)
end
subject
end
def unauthorized_message(action, subject)

View File

@ -317,9 +317,11 @@ describe CanCan::Ability do
end
end
it "should not raise access denied exception if ability is authorized to perform an action" do
it "should not raise access denied exception if ability is authorized to perform an action and return subject" do
@ability.can :read, :foo
lambda { @ability.authorize!(:read, :foo) }.should_not raise_error
lambda {
@ability.authorize!(:read, :foo).should == :foo
}.should_not raise_error
end
it "should know when block is used in conditions" do