Permalink
Browse files

Add rspec test for new feature; removed puts statements

  • Loading branch information...
1 parent deb9659 commit 8774a218b3a72c1e6fd653787f822eee2aeabcb2 @hunterae committed Oct 12, 2010
Showing with 10 additions and 2 deletions.
  1. +0 −2 lib/cancan/controller_resource.rb
  2. +10 −0 spec/cancan/controller_resource_spec.rb
@@ -130,10 +130,8 @@ def collection_instance
# If the :shallow option is passed it will use the resource_class if there's no parent
# If the :singleton option is passed it won't use the association because it needs to be handled later.
def resource_base
- puts "The name in parent is #{@options[:name_in_parent]}"
if @options[:through]
if parent_resource
- puts "This is a parent resource"
@options[:singleton] ? parent_resource : parent_resource.send(@options[:name_in_parent] || name.to_s.pluralize)
elsif @options[:shallow]
resource_class
@@ -280,6 +280,16 @@
resource.load_resource
@controller.instance_variable_get(:@project).should == project
end
+
+ it "should allow you to specify the name of the child resource as specified in the parent" do
+ @params.merge!(:action => "show", :id => 123)
+ category = Object.new
+ stub(@controller).category { category }
+ stub(category).children.stub!.find(123) { :some_project }
+ resource = CanCan::ControllerResource.new(@controller, :through => :category, :name_in_parent => :children)
+ resource.load_resource
+ @controller.instance_variable_get(:@project).should == :some_project
+ end
it "should raise ImplementationRemoved when adding :name option" do
lambda {

0 comments on commit 8774a21

Please sign in to comment.