fixing instance loading with :singleton option - closes #310

This commit is contained in:
Ryan Bates 2011-03-18 09:42:30 -07:00
parent 3efa069349
commit 7688025404
2 changed files with 3 additions and 3 deletions

View File

@ -113,7 +113,7 @@ module CanCan
end
def member_action?
new_actions.include?(@params[:action].to_sym) || (@params[:id] && !collection_actions.include?(@params[:action].to_sym))
new_actions.include?(@params[:action].to_sym) || @options[:singleton] || (@params[:id] && !collection_actions.include?(@params[:action].to_sym))
end
# Returns the class used for this resource. This can be overriden by the :class option.

View File

@ -258,8 +258,8 @@ describe CanCan::ControllerResource do
@controller.instance_variable_get(:@project).should == :some_project
end
it "should find record through has_one association with :singleton option" do
@params.merge!(:action => "show", :id => 123)
it "should find record through has_one association with :singleton option without id param" do
@params.merge!(:action => "show", :id => nil)
category = Object.new
@controller.instance_variable_set(:@category, category)
stub(category).project { :some_project }