aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relations_test.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-06-02 14:42:25 +0100
committerPratik Naik <pratiknaik@gmail.com>2010-06-02 14:42:25 +0100
commit4b91daff13be43ed913a97ffc8ad1b3f77fd9690 (patch)
tree8fa53e49312c54f4d6e600c7505db55894e8c30a /activerecord/test/cases/relations_test.rb
parent0570720d667b5fe55aeebfba087064788d4d2ba4 (diff)
downloadrails-4b91daff13be43ed913a97ffc8ad1b3f77fd9690.tar.gz
rails-4b91daff13be43ed913a97ffc8ad1b3f77fd9690.tar.bz2
rails-4b91daff13be43ed913a97ffc8ad1b3f77fd9690.zip
Special treatement for Relation#select { with block }
Diffstat (limited to 'activerecord/test/cases/relations_test.rb')
-rw-r--r--activerecord/test/cases/relations_test.rb5
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