pass action and subject through AccessDenied exception when :through isn't found - closes #366
This commit is contained in:
parent
74c9d582b2
commit
843fe89c63
|
@ -159,7 +159,7 @@ module CanCan
|
||||||
elsif @options[:shallow]
|
elsif @options[:shallow]
|
||||||
resource_class
|
resource_class
|
||||||
else
|
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
|
end
|
||||||
else
|
else
|
||||||
resource_class
|
resource_class
|
||||||
|
|
|
@ -235,7 +235,10 @@ describe CanCan::ControllerResource do
|
||||||
resource = CanCan::ControllerResource.new(@controller, :through => :category)
|
resource = CanCan::ControllerResource.new(@controller, :through => :category)
|
||||||
lambda {
|
lambda {
|
||||||
resource.load_resource
|
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
|
@controller.instance_variable_get(:@project).should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user