Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #675 from bukalapak/master

porting #668 to master branch
  • Loading branch information...
commit 60cf6a67ef59c0c9b63bc27ea0101125c4193ea6 2 parents ff2b632 + ce7d3fe
@ryanb authored
View
2  lib/cancan/controller_resource.rb
@@ -227,7 +227,7 @@ def resource_params_by_namespaced_name
end
def namespace
- @params[:controller].split("::")[0..-2]
+ @params[:controller].split(/::|\//)[0..-2]
end
def namespaced_name
View
10 spec/cancan/controller_resource_spec.rb
@@ -67,6 +67,16 @@ class Project < ::Project; end
@controller.instance_variable_get(:@project).should == project
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
@params.merge!(:action => "create", :project => {:name => "foobar"})
resource = CanCan::ControllerResource.new(@controller)
Please sign in to comment.
Something went wrong with that request. Please try again.