:id_param option to load_resource allows specification of the param name to find members

This commit is contained in:
Geoff Parsons
2011-07-20 13:42:24 -04:00
parent 600a3e16a5
commit 7937a282a3
2 changed files with 15 additions and 3 deletions
+9 -1
View File
@@ -327,7 +327,15 @@ describe CanCan::ControllerResource do
lambda { resource.load_and_authorize_resource }.should raise_error(CanCan::AccessDenied)
@controller.instance_variable_get(:@custom_project).should == project
end
it "should load resource using custom ID param" do
project = Project.create!
@params.merge!(:action => "show", :the_project => project.id)
resource = CanCan::ControllerResource.new(@controller, :id_param => :the_project)
resource.load_resource
@controller.instance_variable_get(:@project).should == project
end
it "should load resource using custom find_by attribute" do
project = Project.create!(:name => "foo")
@params.merge!(:action => "show", :id => "foo")