aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-09-26 08:45:53 -0700
committerJon Leighton <j@jonathanleighton.com>2011-09-26 16:52:23 +0100
commit89e98e278abe8564b80953855fcb4bcb9871c51c (patch)
tree68783884a5229c5d0b00f1ec5dbe4f0add9d292f /activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
parentd6cff931520d9cd29eeff3c867ef200acaae96ae (diff)
downloadrails-89e98e278abe8564b80953855fcb4bcb9871c51c.tar.gz
rails-89e98e278abe8564b80953855fcb4bcb9871c51c.tar.bz2
rails-89e98e278abe8564b80953855fcb4bcb9871c51c.zip
Merge pull request #3030 from htanata/fix_habtm_select_query_method
Fix: habtm doesn't respect select query method
Diffstat (limited to 'activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
index d8d2a113ff..d1d02c25d5 100644
--- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -650,6 +650,14 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
assert_respond_to categories(:technology).select_testing_posts.find(:first), :correctness_marker
end
+ def test_habtm_selects_all_columns_by_default
+ assert_equal Project.column_names, developers(:david).projects.first.attributes.keys
+ end
+
+ def test_habtm_respects_select_query_method
+ assert_equal ['id'], developers(:david).projects.select(:id).first.attributes.keys
+ end
+
def test_join_table_alias
assert_equal 3, Developer.find(:all, :include => {:projects => :developers}, :conditions => 'developers_projects_join.joined_on IS NOT NULL').size
end