提交 9a253150 编写于 作者: P Pratik Naik

Add extra hash conditions tests for named_scope

上级 cd994eff
......@@ -65,6 +65,10 @@ def test_scopes_with_string_name_can_be_composed
assert_equal Topic.replied.approved, Topic.replied.approved_as_string
end
def test_scopes_can_be_specified_with_deep_hash_conditions
assert_equal Topic.replied.approved, Topic.replied.approved_as_hash_condition
end
def test_scopes_are_composable
assert_equal (approved = Topic.find(:all, :conditions => {:approved => true})), Topic.approved
assert_equal (replied = Topic.find(:all, :conditions => 'replies_count > 0')), Topic.replied
......
......@@ -4,6 +4,7 @@ class Topic < ActiveRecord::Base
{ :conditions => ['written_on < ?', time] }
}
named_scope :approved, :conditions => {:approved => true}
named_scope :approved_as_hash_condition, :conditions => {:topics => {:approved => true}}
named_scope 'approved_as_string', :conditions => {:approved => true}
named_scope :replied, :conditions => ['replies_count > 0']
named_scope :anonymous_extension do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册