aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/calculations_test.rb
diff options
context:
space:
mode:
authorBogdan Gusiev <agresso@gmail.com>2012-02-08 16:37:27 +0200
committerBogdan Gusiev <agresso@gmail.com>2012-02-08 16:37:27 +0200
commita379cb2fb5c61f3108593ff96a74ca9c99300b09 (patch)
tree87963b7855db57e3935dd3227e14099be39fcc4b /activerecord/test/cases/calculations_test.rb
parent17497e5c557ce49f9fbaebf9a290b2a9fa216b8a (diff)
downloadrails-a379cb2fb5c61f3108593ff96a74ca9c99300b09.tar.gz
rails-a379cb2fb5c61f3108593ff96a74ca9c99300b09.tar.bz2
rails-a379cb2fb5c61f3108593ff96a74ca9c99300b09.zip
AR::Relation#pluck: improve to work with joins
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r--activerecord/test/cases/calculations_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index 7c9ebf528e..91d0af4872 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -478,4 +478,15 @@ class CalculationsTest < ActiveRecord::TestCase
def test_pluck_with_qualified_column_name
assert_equal [1,2,3,4], Topic.order(:id).pluck("topics.id")
end
+
+ def test_pluck_auto_table_name_prefix
+ c = Company.create!(:name => "test", :contracts => [Contract.new])
+ assert_equal [c.id], Company.joins(:contracts).pluck(:id)
+ end
+
+ def test_pluck_not_auto_table_name_prefix_if_column_joined
+ c = Company.create!(:name => "test", :contracts => [Contract.new(:developer_id => 7)])
+ # No chance for typecast here
+ assert_equal ["7"], Company.joins(:contracts).pluck(:developer_id)
+ end
end