diff options
Diffstat (limited to 'activerecord/test/cases/method_scoping_test.rb')
-rw-r--r-- | activerecord/test/cases/method_scoping_test.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb index 4ac0018144..6372b4f6aa 100644 --- a/activerecord/test/cases/method_scoping_test.rb +++ b/activerecord/test/cases/method_scoping_test.rb @@ -532,7 +532,7 @@ class DefaultScopingTest < ActiveRecord::TestCase end def test_default_scoping_with_threads - scope = [{:create=>nil, :find=>{:order=>"salary DESC"}}] + scope = [{ :create => {}, :find => { :order => 'salary DESC' } }] 2.times do Thread.new { assert_equal scope, DeveloperOrderedBySalary.send(:scoped_methods) }.join @@ -540,14 +540,14 @@ class DefaultScopingTest < ActiveRecord::TestCase end def test_default_scoping_with_inheritance - scope = [{:create=>nil, :find=>{:order=>"salary DESC"}}] + scope = [{ :create => {}, :find => { :order => 'salary DESC' } }] # Inherit a class having a default scope and define a new default scope klass = Class.new(DeveloperOrderedBySalary) klass.send :default_scope, {} # Scopes added on children should append to parent scope - expected_klass_scope = [{:create=>nil, :find=>{:order=>"salary DESC"}}, {:create=>nil, :find=>{}}] + expected_klass_scope = [{ :create => {}, :find => { :order => 'salary DESC' }}, { :create => {}, :find => {} }] assert_equal expected_klass_scope, klass.send(:scoped_methods) # Parent should still have the original scope @@ -568,6 +568,12 @@ class DefaultScopingTest < ActiveRecord::TestCase assert_equal expected, received end + def test_named_scope + expected = Developer.find(:all, :order => 'name DESC').collect { |dev| dev.salary } + received = DeveloperOrderedBySalary.by_name.find(:all).collect { |dev| dev.salary } + assert_equal expected, received + end + def test_nested_exclusive_scope expected = Developer.find(:all, :limit => 100).collect { |dev| dev.salary } received = DeveloperOrderedBySalary.with_exclusive_scope(:find => { :limit => 100 }) do |