Permalink
Browse files

Failling test for nested resources with a scope for conditions

  • Loading branch information...
1 parent 7bcfd3d commit 81f00f902422c1de6bb578a6334967ce8f8fc809 @flop flop committed Apr 1, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 spec/cancan/model_adapters/active_record_adapter_spec.rb
@@ -125,6 +125,15 @@
Article.accessible_by(@ability).should == [article1]
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
@ability.can :read, Article, :published => true
@ability.can :read, Article, Article.where(:secret => true)

0 comments on commit 81f00f9

Please sign in to comment.