Add code for fixing issue #664 (regression in 1.6.8).
This commit is contained in:
@@ -75,13 +75,19 @@ describe CanCan::ControllerResource do
|
||||
end
|
||||
|
||||
it "should build a new resource for namespaced model with hash if params[:id] is not specified" do
|
||||
project = Sub::Project.create!
|
||||
@params.merge!(:action => "create", 'sub_project' => {:name => "foobar"})
|
||||
resource = CanCan::ControllerResource.new(@controller, :class => ::Sub::Project)
|
||||
resource.load_resource
|
||||
@controller.instance_variable_get(:@project).name.should == "foobar"
|
||||
end
|
||||
|
||||
it "should build a new resource for namespaced controller and namespaced model with hash if params[:id] is not specified" do
|
||||
@params.merge!(:controller => "Admin::SubProjectsController", :action => "create", 'sub_project' => {:name => "foobar"})
|
||||
resource = CanCan::ControllerResource.new(@controller, :class => Project)
|
||||
resource.load_resource
|
||||
@controller.instance_variable_get(:@sub_project).name.should == "foobar"
|
||||
end
|
||||
|
||||
it "should build a new resource with attributes from current ability" do
|
||||
@params.merge!(:action => "new")
|
||||
@ability.can(:create, Project, :name => "from conditions")
|
||||
|
||||
Reference in New Issue
Block a user