properly handle Admin::AbilitiesController in params[:controller] - closes #46
This commit is contained in:
parent
6e1e96c85a
commit
f2a1695636
|
@ -48,7 +48,7 @@ module CanCan
|
|||
end
|
||||
|
||||
def model_name
|
||||
params[:controller].split('/').last.singularize
|
||||
params[:controller].sub("Controller", "").underscore.split('/').last.singularize
|
||||
end
|
||||
|
||||
def collection_actions
|
||||
|
|
|
@ -20,6 +20,13 @@ describe CanCan::ResourceAuthorization do
|
|||
@controller.instance_variable_get(:@ability).should == :some_resource
|
||||
end
|
||||
|
||||
it "should properly load resource for namespaced controller when using '::' for namespace" do
|
||||
stub(Ability).find(123) { :some_resource }
|
||||
authorization = CanCan::ResourceAuthorization.new(@controller, :controller => "Admin::AbilitiesController", :action => "show", :id => 123)
|
||||
authorization.load_resource
|
||||
@controller.instance_variable_get(:@ability).should == :some_resource
|
||||
end
|
||||
|
||||
it "should build a new resource with hash if params[:id] is not specified" do
|
||||
stub(Ability).new(:foo => "bar") { :some_resource }
|
||||
authorization = CanCan::ResourceAuthorization.new(@controller, :controller => "abilities", :action => "create", :ability => {:foo => "bar"})
|
||||
|
|
Loading…
Reference in New Issue
Block a user