diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-07-09 05:20:42 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-07-09 05:20:42 -0700 |
commit | bc364afb9333cb7729452adf09fc70ccac510226 (patch) | |
tree | ed5e8450873ef013e3f84797bd74857952b624b1 /activerecord/test | |
parent | 111968d4024fdccc386979551cdfc7799b39cff0 (diff) | |
parent | 7c921fbf1572698dd9541426b05b70d1c951cbe5 (diff) | |
download | rails-bc364afb9333cb7729452adf09fc70ccac510226.tar.gz rails-bc364afb9333cb7729452adf09fc70ccac510226.tar.bz2 rails-bc364afb9333cb7729452adf09fc70ccac510226.zip |
Merge pull request #2007 from amatsuda/having_vargs_nomethoderror_fix
having() raises NoMethodError: undefined method `empty?' when the given argument does not respond to empty?
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 4e75eafe3d..3d2a03d2b9 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -140,23 +140,30 @@ class FinderTest < ActiveRecord::TestCase def test_find_with_group - developers = Developer.find(:all, :group => "salary", :select => "salary") + developers = Developer.find(:all, :group => "salary", :select => "salary") assert_equal 4, developers.size assert_equal 4, developers.map(&:salary).uniq.size end def test_find_with_group_and_having - developers = Developer.find(:all, :group => "salary", :having => "sum(salary) > 10000", :select => "salary") + developers = Developer.find(:all, :group => "salary", :having => "sum(salary) > 10000", :select => "salary") assert_equal 3, developers.size assert_equal 3, developers.map(&:salary).uniq.size - assert developers.all? { |developer| developer.salary > 10000 } + assert developers.all? { |developer| developer.salary > 10000 } end def test_find_with_group_and_sanitized_having - developers = Developer.find(:all, :group => "salary", :having => ["sum(salary) > ?", 10000], :select => "salary") + developers = Developer.find(:all, :group => "salary", :having => ["sum(salary) > ?", 10000], :select => "salary") assert_equal 3, developers.size assert_equal 3, developers.map(&:salary).uniq.size - assert developers.all? { |developer| developer.salary > 10000 } + assert developers.all? { |developer| developer.salary > 10000 } + end + + def test_find_with_group_and_sanitized_having_method + developers = Developer.group(:salary).having("sum(salary) > ?", 10000).select('salary').all + assert_equal 3, developers.size + assert_equal 3, developers.map(&:salary).uniq.size + assert developers.all? { |developer| developer.salary > 10000 } end def test_find_with_entire_select_statement |