Skip to content

Commit

Permalink
pass action and subject through AccessDenied exception when :through …
Browse files Browse the repository at this point in the history
…isn't found - closes ryanb#366
  • Loading branch information
ryanb committed May 18, 2011
1 parent 74c9d58 commit 843fe89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/cancan/controller_resource.rb
Expand Up @@ -159,7 +159,7 @@ def resource_base
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
Expand Down
5 changes: 4 additions & 1 deletion spec/cancan/controller_resource_spec.rb
Expand Up @@ -235,7 +235,10 @@
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

Expand Down

0 comments on commit 843fe89

Please sign in to comment.