Failling test for nested resources with a scope for conditions
This commit is contained in:
		
							parent
							
								
									7bcfd3d295
								
							
						
					
					
						commit
						81f00f9024
					
				@ -125,6 +125,15 @@ if ENV["MODEL_ADAPTER"].nil? || ENV["MODEL_ADAPTER"] == "active_record"
 | 
				
			|||||||
      Article.accessible_by(@ability).should == [article1]
 | 
					      Article.accessible_by(@ability).should == [article1]
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it "should only fetch associated records for nested controllers" do
 | 
				
			||||||
 | 
					      @ability.can :read, Article, Article.where(:secret => true)
 | 
				
			||||||
 | 
					      category1 = Category.create!(:visible => false)
 | 
				
			||||||
 | 
					      category2 = Category.create!(:visible => true)
 | 
				
			||||||
 | 
					      article1 = Article.create!(:secret => true, :category => category1)
 | 
				
			||||||
 | 
					      article2 = Article.create!(:secret => true, :category => category2)
 | 
				
			||||||
 | 
					      category1.articles.accessible_by(@ability).should == [article1]
 | 
				
			||||||
 | 
					    end    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it "should raise an exception when trying to merge scope with other conditions" do
 | 
					    it "should raise an exception when trying to merge scope with other conditions" do
 | 
				
			||||||
      @ability.can :read, Article, :published => true
 | 
					      @ability.can :read, Article, :published => true
 | 
				
			||||||
      @ability.can :read, Article, Article.where(:secret => true)
 | 
					      @ability.can :read, Article, Article.where(:secret => true)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user