allow query.conditions to be called multiple times without losing conditions

This commit is contained in:
Ryan Bates
2010-12-21 14:01:28 -08:00
parent 9b8e84944c
commit 5e1e6e182b
2 changed files with 11 additions and 2 deletions

View File

@@ -104,4 +104,13 @@ describe CanCan::Query do
@ability.can :read, Project, :project => { :foo => {:bar => true}, :bar => {:zip => :zap} }
@ability.query(:read, Project).joins.inspect.should orderlessly_match([{:project => [:bar, :foo]}, {:company => [:bar]}].inspect)
end
it "should not forget conditions when calling with SQL string" do
@ability.can :read, Project, :foo => 1
@ability.can :read, Project, ['bar = ?', 1]
query = @ability.query(:read, Project)
2.times do
query.conditions.should == "(bar = 1) OR (foo=1)"
end
end
end