Named resources were not being loaded correctly. Fixes #633
This commit is contained in:
parent
ccd24ab30f
commit
78cbcf1db9
|
@ -145,7 +145,7 @@ module CanCan
|
||||||
def resource_class
|
def resource_class
|
||||||
case @options[:class]
|
case @options[:class]
|
||||||
when false then name.to_sym
|
when false then name.to_sym
|
||||||
when nil then namespaced_name.to_s.camelize.constantize
|
when nil then (@name || namespaced_name).to_s.classify.constantize
|
||||||
when String then @options[:class].constantize
|
when String then @options[:class].constantize
|
||||||
else @options[:class]
|
else @options[:class]
|
||||||
end
|
end
|
||||||
|
|
|
@ -223,6 +223,19 @@ describe CanCan::ControllerResource do
|
||||||
@controller.instance_variable_get(:@project).should be_nil
|
@controller.instance_variable_get(:@project).should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "named resources should not be loaded independently of the controller" do
|
||||||
|
category = Category.create!
|
||||||
|
@params.merge!(:action => "new", :category_id => category.id)
|
||||||
|
|
||||||
|
CanCan::ControllerResource.new(@controller, :category, :load => true).process
|
||||||
|
CanCan::ControllerResource.new(@controller, :project, :load => true, :through => :category).process
|
||||||
|
|
||||||
|
@controller.instance_variable_get(:@category).should eq(category)
|
||||||
|
|
||||||
|
project = @controller.instance_variable_get(:@project)
|
||||||
|
project.category.should eq(category)
|
||||||
|
end
|
||||||
|
|
||||||
it "authorizes nested resource through parent association on index action" do
|
it "authorizes nested resource through parent association on index action" do
|
||||||
pending
|
pending
|
||||||
@params.merge!(:action => "index")
|
@params.merge!(:action => "index")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user