adding :name option to load_and_authorize_resource if it does not match controller - closes #65

This commit is contained in:
Ryan Bates
2010-05-21 14:20:45 -07:00
parent dfd84a10ed
commit 2a3dd85a18
4 changed files with 20 additions and 1 deletions

View File

@@ -114,4 +114,11 @@ describe CanCan::ResourceAuthorization do
authorization.load_resource
@controller.instance_variable_get(:@ability).should == :some_resource
end
it "should use :name option to determine resource name" do
stub(Ability).find(123) { :some_resource }
authorization = CanCan::ResourceAuthorization.new(@controller, {:controller => "foo", :action => "show", :id => 123}, {:name => :ability})
authorization.load_resource
@controller.instance_variable_get(:@ability).should == :some_resource
end
end