aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-09-17 06:40:38 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-09-17 10:46:19 -0300
commitee439895759b38431ad025f3c234831f30dadcdb (patch)
tree5d4cb9e79617a0a41ee71cb11caef14b83a2eb6b /activerecord/test
parent07c8055dc05c954c7f61006fcad85997be2c04a1 (diff)
downloadrails-ee439895759b38431ad025f3c234831f30dadcdb.tar.gz
rails-ee439895759b38431ad025f3c234831f30dadcdb.tar.bz2
rails-ee439895759b38431ad025f3c234831f30dadcdb.zip
Merge pull request #7661 from ernie/build-join-records-on-unsaved-hmt
Fix collection= on hm:t join models when unsaved
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb
index 4489c3e638..e4710eb61b 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -845,6 +845,11 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
end
end
+ def test_assign_array_to_new_record_builds_join_records
+ c = Category.new(:name => 'Fishing', :authors => [Author.first])
+ assert_equal 1, c.categorizations.size
+ end
+
def test_create_bang_should_raise_exception_when_join_record_has_errors
repair_validations(Categorization) do
Categorization.validate { |r| r.errors[:base] << 'Invalid Categorization' }