Merge pull request #675 from bukalapak/master
porting #668 to master branch
This commit is contained in:
commit
60cf6a67ef
|
@ -227,7 +227,7 @@ module CanCan
|
||||||
end
|
end
|
||||||
|
|
||||||
def namespace
|
def namespace
|
||||||
@params[:controller].split("::")[0..-2]
|
@params[:controller].split(/::|\//)[0..-2]
|
||||||
end
|
end
|
||||||
|
|
||||||
def namespaced_name
|
def namespaced_name
|
||||||
|
|
|
@ -67,6 +67,16 @@ describe CanCan::ControllerResource do
|
||||||
@controller.instance_variable_get(:@project).should == project
|
@controller.instance_variable_get(:@project).should == project
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "has the specified nested resource_class when using / for namespace" do
|
||||||
|
module Admin
|
||||||
|
class Dashboard; end
|
||||||
|
end
|
||||||
|
@ability.can(:index, "admin/dashboard")
|
||||||
|
@params.merge!(:controller => "admin/dashboard", :action => "index")
|
||||||
|
resource = CanCan::ControllerResource.new(@controller, :authorize => true)
|
||||||
|
resource.send(:resource_class).should == Admin::Dashboard
|
||||||
|
end
|
||||||
|
|
||||||
it "should build a new resource with hash if params[:id] is not specified" do
|
it "should build a new resource with hash if params[:id] is not specified" do
|
||||||
@params.merge!(:action => "create", :project => {:name => "foobar"})
|
@params.merge!(:action => "create", :project => {:name => "foobar"})
|
||||||
resource = CanCan::ControllerResource.new(@controller)
|
resource = CanCan::ControllerResource.new(@controller)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user