diff options
author | Akira Matsuda <ronnie@dio.jp> | 2011-07-08 12:16:32 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2011-07-09 20:14:41 +0900 |
commit | d1545bcf94af287fca1fc34e0f9c7cfda56ff130 (patch) | |
tree | bc4c292b99397001ab79bb02a8b744a88f8ad283 /activerecord/test/cases | |
parent | 111968d4024fdccc386979551cdfc7799b39cff0 (diff) | |
download | rails-d1545bcf94af287fca1fc34e0f9c7cfda56ff130.tar.gz rails-d1545bcf94af287fca1fc34e0f9c7cfda56ff130.tar.bz2 rails-d1545bcf94af287fca1fc34e0f9c7cfda56ff130.zip |
fix AR having() not to raise NoMethodError when the given argument does not respond to empty?
having raises NoMethodError: undefined method `empty?' when a Fixnum or Date/Time were passed via varargs
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 4e75eafe3d..8f392609df 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -159,6 +159,13 @@ class FinderTest < ActiveRecord::TestCase 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 topics = Topic.find_by_sql "SELECT * FROM topics WHERE author_name = 'Mary'" |