Pass :only and :except options to before filters for load/authorize resource methods.

This commit is contained in:
Ryan Bates
2009-12-13 11:00:12 -08:00
parent 63634b4f5d
commit 94e031bf96
3 changed files with 27 additions and 11 deletions

View File

@@ -29,19 +29,19 @@ describe CanCan::ControllerAdditions do
it "load_and_authorize_resource should setup a before filter which passes call to ResourceAuthorization" do
stub(CanCan::ResourceAuthorization).new(@controller, @controller.params, :foo => :bar).mock!.load_and_authorize_resource
mock(@controller_class).before_filter { |block| block.call(@controller) }
mock(@controller_class).before_filter({}) { |options, block| block.call(@controller) }
@controller_class.load_and_authorize_resource :foo => :bar
end
it "authorize_resource should setup a before filter which passes call to ResourceAuthorization" do
stub(CanCan::ResourceAuthorization).new(@controller, @controller.params, :foo => :bar).mock!.authorize_resource
mock(@controller_class).before_filter { |block| block.call(@controller) }
@controller_class.authorize_resource :foo => :bar
mock(@controller_class).before_filter(:except => :show) { |options, block| block.call(@controller) }
@controller_class.authorize_resource :foo => :bar, :except => :show
end
it "load_resource should setup a before filter which passes call to ResourceAuthorization" do
stub(CanCan::ResourceAuthorization).new(@controller, @controller.params, :foo => :bar).mock!.load_resource
mock(@controller_class).before_filter { |block| block.call(@controller) }
@controller_class.load_resource :foo => :bar
mock(@controller_class).before_filter(:only => [:show, :index]) { |options, block| block.call(@controller) }
@controller_class.load_resource :foo => :bar, :only => [:show, :index]
end
end