From 0e8c7ca01f633d238d9ad44151390cc619e75e8d Mon Sep 17 00:00:00 2001 From: Michael de Silva Date: Sat, 3 Mar 2012 01:45:25 +0300 Subject: [PATCH] cancan 2.0 fix for issue #565; test to properly authorize resource for namespaced controller --- spec/cancan/controller_resource_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/cancan/controller_resource_spec.rb b/spec/cancan/controller_resource_spec.rb index 3ae03d8..bfc2bcc 100644 --- a/spec/cancan/controller_resource_spec.rb +++ b/spec/cancan/controller_resource_spec.rb @@ -384,6 +384,14 @@ describe CanCan::ControllerResource do @controller.instance_variable_get(:@project).name.should == "foobar" end + it "should properly authorize resource for namespaced controller" do + @ability.can(:index, "admin/dashboard") + @params.merge!(:controller => "admin/dashboard", :action => "index") + @controller.authorize!(:index, "admin/dashboard") + resource = CanCan::ControllerResource.new(@controller, :authorize => true).process + lambda { resource.process }.should_not raise_error(CanCan::Unauthorized) + end + # it "raises ImplementationRemoved when adding :name option" do # lambda { # CanCan::ControllerResource.new(@controller, :name => :foo)