add specs to sql conditions by not Hash

This commit is contained in:
Sokolov Yura 2010-09-13 22:18:06 +08:00 committed by Ryan Bates
parent ff9a91705b
commit 7e0e72276e

View File

@ -48,4 +48,12 @@ describe CanCan::ActiveRecordAdditions do
# @ability.associations_hash(:read, @model_class).should == [{:too => [:far]}, :foo]
@model_class.accessible_by(@ability).should == :found_records
end
it "should allow to define sql conditions by not hash" do
@ability.can :read, @model_class, :foo => 1
@ability.can :read, @model_class, ['bar = ?', 1]
stub(@model_class).scoped( :conditions => '(bar = 1) OR (foo=1)', :joins => nil ) { :found_records }
stub(@model_class).scoped{|*args| args.inspect}
@model_class.accessible_by(@ability).should == :found_records
end
end