Fixes Nested Resource Loading
This commit is contained in:
parent
7bf683d8f4
commit
d5baed6281
|
@ -215,8 +215,12 @@ module CanCan
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def namespace
|
||||||
|
@params[:controller].split("::")[0..-2]
|
||||||
|
end
|
||||||
|
|
||||||
def namespaced_name
|
def namespaced_name
|
||||||
@name || @params[:controller].sub("Controller", "").singularize.camelize.constantize
|
[namespace, name.camelize].join('::').singularize.camelize.constantize
|
||||||
rescue NameError
|
rescue NameError
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
|
|
|
@ -215,6 +215,14 @@ describe CanCan::ControllerResource do
|
||||||
resource.should_not be_parent
|
resource.should_not be_parent
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should have the specified resource_class if 'name' is passed to load_resource" do
|
||||||
|
class Section
|
||||||
|
end
|
||||||
|
|
||||||
|
resource = CanCan::ControllerResource.new(@controller, :section)
|
||||||
|
resource.send(:resource_class).should == Section
|
||||||
|
end
|
||||||
|
|
||||||
it "should load parent resource through proper id parameter" do
|
it "should load parent resource through proper id parameter" do
|
||||||
project = Project.create!
|
project = Project.create!
|
||||||
@params.merge!(:controller => "categories", :action => "index", :project_id => project.id)
|
@params.merge!(:controller => "categories", :action => "index", :project_id => project.id)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user