Spec to test against nested joins being thrown away ala issue 560

This commit is contained in:
David Mike Simon 2012-06-19 16:58:15 -07:00
parent cfc355c006
commit b162871c6d

View File

@ -227,6 +227,12 @@ if ENV["MODEL_ADAPTER"].nil? || ENV["MODEL_ADAPTER"] == "active_record"
@ability.model_adapter(Article, :read).joins.should == [:project] @ability.model_adapter(Article, :read).joins.should == [:project]
end end
it "should merge nested and non-nested joins" do
@ability.can :read, Article, :project => { :blocked => false }
@ability.can :read, Article, :project => { :comments => { :spam => true } }
@ability.model_adapter(Article, :read).joins.should == [{:project=>[:comments]}]
end
it "should restrict articles given a MetaWhere condition" do it "should restrict articles given a MetaWhere condition" do
@ability.can :read, Article, :priority.lt => 2 @ability.can :read, Article, :priority.lt => 2
article1 = Article.create!(:priority => 1) article1 = Article.create!(:priority => 1)