Merge branch 'master' into 2.0
This commit is contained in:
		
						commit
						67c93619c1
					
				@ -128,11 +128,15 @@ module CanCan
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def id_param
 | 
			
		||||
      @params[parent? ? :"#{name}_id" : :id]
 | 
			
		||||
      if @options[:id_param]
 | 
			
		||||
        @params[@options[:id_param]]
 | 
			
		||||
      else
 | 
			
		||||
        @params[parent? ? :"#{name}_id" : :id]
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def member_action?
 | 
			
		||||
      new_actions.include?(@params[:action].to_sym) || @options[:singleton] || (@params[:id] && !collection_actions.include?(@params[:action].to_sym))
 | 
			
		||||
      new_actions.include?(@params[:action].to_sym) || @options[:singleton] || ( (@params[:id] || @params[@options[:id_param]]) && !collection_actions.include?(@params[:action].to_sym))
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Returns the class used for this resource. This can be overriden by the :class option.
 | 
			
		||||
 | 
			
		||||
@ -325,7 +325,15 @@ describe CanCan::ControllerResource do
 | 
			
		||||
    lambda { resource.process }.should raise_error(CanCan::Unauthorized)
 | 
			
		||||
    @controller.instance_variable_get(:@custom_project).should == project
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
  it "should load resource using custom ID param" do
 | 
			
		||||
    project = Project.create!
 | 
			
		||||
    @params.merge!(:action => "show", :the_project => project.id)
 | 
			
		||||
    resource = CanCan::ControllerResource.new(@controller, :id_param => :the_project)
 | 
			
		||||
    resource.load_resource
 | 
			
		||||
    @controller.instance_variable_get(:@project).should == project
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  it "should load resource using custom find_by attribute" do
 | 
			
		||||
    project = Project.create!(:name => "foo")
 | 
			
		||||
    @params.merge!(:action => "show", :id => "foo")
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user