Don't fetch parent of nested resource if *_id parameter is missing so it works with shallow nested routes - closes #14

This commit is contained in:
Ryan Bates
2009-12-14 08:18:08 -08:00
parent f7480d1f5a
commit e9f01300b6
3 changed files with 19 additions and 2 deletions

View File

@@ -96,4 +96,13 @@ describe CanCan::ResourceAuthorization do
authorization.load_resource
@controller.instance_variable_get(:@ability).should == :some_ability
end
it "should not load nested resource and build through this if *_id param isn't specified" do
stub(Person).find(456) { :some_person }
stub(Ability).new(nil) { :some_ability }
authorization = CanCan::ResourceAuthorization.new(@controller, {:controller => "abilities", :action => "new", :person_id => 456}, {:nested => [:person, :behavior]})
authorization.load_resource
@controller.instance_variable_get(:@person).should == :some_person
@controller.instance_variable_get(:@ability).should == :some_ability
end
end