diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-06-02 14:42:25 +0100 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-06-03 23:32:12 +1000 |
commit | a9753637f4fcb68f65da96c85dfcb74ca1c13184 (patch) | |
tree | 7971b135e43f54b4b006730519bdf31da747e9c0 /activerecord/test | |
parent | 8aca1c09db1cb74a5b59aaa454fb7f551ccb6de0 (diff) | |
download | rails-a9753637f4fcb68f65da96c85dfcb74ca1c13184.tar.gz rails-a9753637f4fcb68f65da96c85dfcb74ca1c13184.tar.bz2 rails-a9753637f4fcb68f65da96c85dfcb74ca1c13184.zip |
Special treatement for Relation#select { with block }
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index b6815af67e..4097c5119e 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -112,6 +112,11 @@ class RelationTest < ActiveRecord::TestCase assert_equal 4, developers.map(&:salary).uniq.size end + def test_select_with_block + even_ids = Developer.scoped.select {|d| d.id % 2 == 0 }.map(&:id) + assert_equal [2, 4, 6, 8, 10], even_ids + end + def test_finding_with_hash_conditions_on_joined_table firms = DependentFirm.joins(:account).where({:name => 'RailsCore', :accounts => { :credit_limit => 55..60 }}).to_a assert_equal 1, firms.size |