renaming skip_authorization to skip_authorization_check - closes #169
This commit is contained in:
parent
92995d791e
commit
787511a208
|
@ -176,11 +176,11 @@ module CanCan
|
||||||
#
|
#
|
||||||
# Any arguments are passed to the +after_filter+ it triggers.
|
# Any arguments are passed to the +after_filter+ it triggers.
|
||||||
#
|
#
|
||||||
# See skip_authorization to bypass this check on specific controller actions.
|
# See skip_authorization_check to bypass this check on specific controller actions.
|
||||||
def check_authorization(*args)
|
def check_authorization(*args)
|
||||||
self.after_filter(*args) do |controller|
|
self.after_filter(*args) do |controller|
|
||||||
unless controller.instance_variable_defined?(:@_authorized)
|
unless controller.instance_variable_defined?(:@_authorized)
|
||||||
raise AuthorizationNotPerformed, "This action failed the check_authorization because it does not authorize_resource. Add skip_authorization to bypass this check."
|
raise AuthorizationNotPerformed, "This action failed the check_authorization because it does not authorize_resource. Add skip_authorization_check to bypass this check."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -188,16 +188,20 @@ module CanCan
|
||||||
# Call this in the class of a controller to skip the check_authorization behavior on the actions.
|
# Call this in the class of a controller to skip the check_authorization behavior on the actions.
|
||||||
#
|
#
|
||||||
# class HomeController < ApplicationController
|
# class HomeController < ApplicationController
|
||||||
# skip_authorization :only => :index
|
# skip_authorization_check :only => :index
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# Any arguments are passed to the +before_filter+ it triggers.
|
# Any arguments are passed to the +before_filter+ it triggers.
|
||||||
def skip_authorization(*args)
|
def skip_authorization_check(*args)
|
||||||
self.before_filter(*args) do |controller|
|
self.before_filter(*args) do |controller|
|
||||||
controller.instance_variable_set(:@_authorized, true)
|
controller.instance_variable_set(:@_authorized, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def skip_authorization(*args)
|
||||||
|
raise ImplementationRemoved, "The CanCan skip_authorization method has been renamed to skip_authorization_check. Please update your code."
|
||||||
|
end
|
||||||
|
|
||||||
def cancan_resource_class
|
def cancan_resource_class
|
||||||
if ancestors.map(&:to_s).include? "InheritedResources::Actions"
|
if ancestors.map(&:to_s).include? "InheritedResources::Actions"
|
||||||
InheritedResource
|
InheritedResource
|
||||||
|
|
|
@ -54,9 +54,9 @@ describe CanCan::ControllerAdditions do
|
||||||
@controller_class.load_resource :foo => :bar, :only => [:show, :index]
|
@controller_class.load_resource :foo => :bar, :only => [:show, :index]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "skip_authorization should set up a before filter which sets @_authorized to true" do
|
it "skip_authorization_check should set up a before filter which sets @_authorized to true" do
|
||||||
mock(@controller_class).before_filter(:filter_options) { |options, block| block.call(@controller) }
|
mock(@controller_class).before_filter(:filter_options) { |options, block| block.call(@controller) }
|
||||||
@controller_class.skip_authorization(:filter_options)
|
@controller_class.skip_authorization_check(:filter_options)
|
||||||
@controller.instance_variable_get(:@_authorized).should be_true
|
@controller.instance_variable_get(:@_authorized).should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user