allow :parent => false option to work in load/authorize resource
This commit is contained in:
parent
c9e0f4e3ef
commit
75ce2bdefa
|
@ -34,7 +34,7 @@ module CanCan
|
||||||
end
|
end
|
||||||
|
|
||||||
def parent?
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -122,6 +122,11 @@ describe CanCan::ControllerResource do
|
||||||
resource.should be_parent
|
resource.should be_parent
|
||||||
end
|
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
|
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)
|
@params.merge!(:action => "index", :person_id => 123)
|
||||||
stub(Person).find(123) { :some_person }
|
stub(Person).find(123) { :some_person }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user