Permalink
Browse files

don't pass nil to 'new' call when no params are specified - closes #63

  • Loading branch information...
1 parent 156839b commit 67b069579ef34fba5f576e913e0547792a4dce9d @ryanb committed Aug 5, 2010
Showing with 4 additions and 4 deletions.
  1. +1 −1 lib/cancan/controller_resource.rb
  2. +3 −3 spec/cancan/controller_resource_spec.rb
@@ -41,7 +41,7 @@ def parent?
def load_resource_instance
if !parent? && new_actions.include?(@params[:action].to_sym)
- resource_base.kind_of?(Class) ? resource_base.new(@params[name.to_sym]) : resource_base.build(@params[name.to_sym])
+ @params[name.to_sym] ? resource_base.new(@params[name.to_sym]) : resource_base.new
elsif id_param
resource_base.find(id_param)
end
@@ -40,8 +40,8 @@
@controller.instance_variable_get(:@ability).should == :some_resource
end
- it "should build a new resource even if attribute hash isn't specified" do
- stub(Ability).new(nil) { :some_resource }
+ it "should build a new resource with no arguments if attribute hash isn't specified" do
+ mock(Ability).new { :some_resource }
resource = CanCan::ControllerResource.new(@controller, :controller => "abilities", :action => "new")
resource.load_resource
@controller.instance_variable_get(:@ability).should == :some_resource
@@ -80,7 +80,7 @@
end
it "should build a resource when on custom new action even when params[:id] exists" do
- stub(Ability).new(nil) { :some_resource }
+ stub(Ability).new { :some_resource }
resource = CanCan::ControllerResource.new(@controller, {:controller => "abilities", :action => "build", :id => 123}, {:new => :build})
resource.load_resource
@controller.instance_variable_get(:@ability).should == :some_resource

0 comments on commit 67b0695

Please sign in to comment.