aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-06-28 01:57:32 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-06-28 01:57:32 +0100
commit9a25315076bf90c39ab5471fa8d81736a3b2478e (patch)
tree5dd3e063849064e806f74db60bfce1eb4f6d6406 /activerecord
parentcd994eff9a343df376bfaec59de5b24a2ab51256 (diff)
downloadrails-9a25315076bf90c39ab5471fa8d81736a3b2478e.tar.gz
rails-9a25315076bf90c39ab5471fa8d81736a3b2478e.tar.bz2
rails-9a25315076bf90c39ab5471fa8d81736a3b2478e.zip
Add extra hash conditions tests for named_scope
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/named_scope_test.rb4
-rwxr-xr-xactiverecord/test/models/topic.rb1
2 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb
index 393ba086c9..7d73541ee1 100644
--- a/activerecord/test/cases/named_scope_test.rb
+++ b/activerecord/test/cases/named_scope_test.rb
@@ -65,6 +65,10 @@ class NamedScopeTest < ActiveRecord::TestCase
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
diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb
index 423b6fe52b..47b2eec938 100755
--- a/activerecord/test/models/topic.rb
+++ b/activerecord/test/models/topic.rb
@@ -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