Browse files

return subject passed to authorize! - closes #314

  • Loading branch information...
1 parent 5d97cfb commit 1ac8099f7a3e2ce7e6b9b37715785ff7c652953b @ryanb committed Mar 25, 2011
Showing with 5 additions and 2 deletions.
  1. +1 −0 lib/cancan/ability.rb
  2. +4 −2 spec/cancan/ability_spec.rb
View
1 lib/cancan/ability.rb
@@ -201,6 +201,7 @@ def authorize!(action, subject, *args)
message ||= unauthorized_message(action, subject)
raise AccessDenied.new(message, action, subject)
end
+ subject
end
def unauthorized_message(action, subject)
View
6 spec/cancan/ability_spec.rb
@@ -317,9 +317,11 @@ class Container < Hash; end
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

0 comments on commit 1ac8099

Please sign in to comment.