allow :parent => false option to work in load/authorize resource

This commit is contained in:
Ryan Bates 2010-08-06 14:26:57 -07:00
parent c9e0f4e3ef
commit 75ce2bdefa
2 changed files with 6 additions and 1 deletions

View File

@ -34,7 +34,7 @@ module CanCan
end
def parent?
@options[:parent] || @name && @name != name_from_controller.to_sym
@options.has_key?(:parent) ? @options[:parent] : @name && @name != name_from_controller.to_sym
end
private

View File

@ -122,6 +122,11 @@ describe CanCan::ControllerResource do
resource.should be_parent
end
it "should not be parent if specified in options" do
resource = CanCan::ControllerResource.new(@controller, :person, {:parent => false})
resource.should_not be_parent
end
it "should load parent resource through proper id parameter when supplying a resource with a different name" do
@params.merge!(:action => "index", :person_id => 123)
stub(Person).find(123) { :some_person }