From 6fd1a4d502b724d198fd42ee59d8271b7a4f3362 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 5 Dec 2007 21:37:51 +0000 Subject: Fixed that habtm associations should be able to set :select as part of their definition and have that honored [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8309 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/associations_test.rb | 6 ++++++ activerecord/test/fixtures/project.rb | 1 + 2 files changed, 7 insertions(+) (limited to 'activerecord') diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index f2a87eec49..42e3e09187 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -1998,6 +1998,12 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase assert_raises(ActiveRecord::ReadOnlyRecord) { david.save! } end + def test_updating_attributes_on_rich_associations_with_limited_find_from_reflection + david = projects(:action_controller).selected_developers.first + david.name = "DHH" + assert_nothing_raised { david.save! } + end + def test_updating_attributes_on_rich_associations_with_limited_find david = projects(:action_controller).developers.find(:all, :select => "developers.*").first diff --git a/activerecord/test/fixtures/project.rb b/activerecord/test/fixtures/project.rb index 2538b99d00..b90d2c6fbc 100644 --- a/activerecord/test/fixtures/project.rb +++ b/activerecord/test/fixtures/project.rb @@ -1,5 +1,6 @@ class Project < ActiveRecord::Base has_and_belongs_to_many :developers, :uniq => true, :order => 'developers.name desc, developers.id desc' + has_and_belongs_to_many :selected_developers, :class_name => "Developer", :select => "developers.*", :uniq => true has_and_belongs_to_many :non_unique_developers, :order => 'developers.name desc, developers.id desc', :class_name => 'Developer' has_and_belongs_to_many :limited_developers, :class_name => "Developer", :limit => 1 has_and_belongs_to_many :developers_named_david, :class_name => "Developer", :conditions => "name = 'David'", :uniq => true -- cgit v1.2.3