pass action and subject through AccessDenied exception when :through isn't found - closes #366

This commit is contained in:
Ryan Bates 2011-05-18 12:58:02 -04:00
parent 74c9d582b2
commit 843fe89c63
2 changed files with 5 additions and 2 deletions

View File

@ -159,7 +159,7 @@ module CanCan
elsif @options[:shallow]
resource_class
else
raise AccessDenied # maybe this should be a record not found error instead?
raise AccessDenied.new(nil, authorization_action, resource_class) # maybe this should be a record not found error instead?
end
else
resource_class

View File

@ -235,7 +235,10 @@ describe CanCan::ControllerResource do
resource = CanCan::ControllerResource.new(@controller, :through => :category)
lambda {
resource.load_resource
}.should raise_error(CanCan::AccessDenied)
}.should raise_error(CanCan::AccessDenied) { |exception|
exception.action.should == :show
exception.subject.should == Project
}
@controller.instance_variable_get(:@project).should be_nil
end