adding :name option to load_and_authorize_resource if it does not match controller - closes #65
This commit is contained in:
parent
dfd84a10ed
commit
2a3dd85a18
|
@ -1,3 +1,5 @@
|
|||
* Adding :name option to load_and_authorize_resource if it does not match controller - see issue #65
|
||||
|
||||
* Fixing issue when using accessible_by with nil can conditions (thanks jrallison) - see issue #66
|
||||
|
||||
* Pluralize table name for belongs_to associations in can conditions hash (thanks logandk) - see issue #62
|
||||
|
|
|
@ -59,6 +59,11 @@ module CanCan
|
|||
#
|
||||
# load_resource :nested => [:publisher, :author]
|
||||
#
|
||||
# [:+name+]
|
||||
# The name of the resource if it cannot be determined from controller (string or symbol).
|
||||
#
|
||||
# load_resource :name => :article
|
||||
#
|
||||
# [:+resource+]
|
||||
# The class to use for the model (string or constant).
|
||||
#
|
||||
|
@ -102,6 +107,11 @@ module CanCan
|
|||
# [:+except+]
|
||||
# Does not apply before filter to given actions.
|
||||
#
|
||||
# [:+name+]
|
||||
# The name of the resource if it cannot be determined from controller (string or symbol).
|
||||
#
|
||||
# load_resource :name => :article
|
||||
#
|
||||
# [:+resource+]
|
||||
# The class to use for the model (string or constant). Alternatively pass a symbol
|
||||
# to represent a resource which does not have a class.
|
||||
|
|
|
@ -54,7 +54,7 @@ module CanCan
|
|||
end
|
||||
|
||||
def model_name
|
||||
@params[:controller].sub("Controller", "").underscore.split('/').last.singularize
|
||||
@options[:name] || @params[:controller].sub("Controller", "").underscore.split('/').last.singularize
|
||||
end
|
||||
|
||||
def collection_actions
|
||||
|
|
|
@ -114,4 +114,11 @@ describe CanCan::ResourceAuthorization do
|
|||
authorization.load_resource
|
||||
@controller.instance_variable_get(:@ability).should == :some_resource
|
||||
end
|
||||
|
||||
it "should use :name option to determine resource name" do
|
||||
stub(Ability).find(123) { :some_resource }
|
||||
authorization = CanCan::ResourceAuthorization.new(@controller, {:controller => "foo", :action => "show", :id => 123}, {:name => :ability})
|
||||
authorization.load_resource
|
||||
@controller.instance_variable_get(:@ability).should == :some_resource
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user