diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-27 08:19:12 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-27 08:19:12 +0000 |
commit | b5b16a80a9e0386781b370cf110fdc26e13dbc61 (patch) | |
tree | 13d82a1de2c4c2b51368736ae9c0cece18a53747 /activerecord/test/associations_test.rb | |
parent | 02311a5db1800a4654f80ec71e8b7d32b444ff27 (diff) | |
download | rails-b5b16a80a9e0386781b370cf110fdc26e13dbc61.tar.gz rails-b5b16a80a9e0386781b370cf110fdc26e13dbc61.tar.bz2 rails-b5b16a80a9e0386781b370cf110fdc26e13dbc61.zip |
Define collection singular ids method for has_many :through associations. Closes #8763.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7137 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_test.rb')
-rwxr-xr-x | activerecord/test/associations_test.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index 93b1da10c6..bf6d8301a2 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -11,6 +11,7 @@ require 'fixtures/categorization' require 'fixtures/category' require 'fixtures/post' require 'fixtures/author' +require 'fixtures/comment' require 'fixtures/tag' require 'fixtures/tagging' @@ -420,7 +421,7 @@ end class HasManyAssociationsTest < Test::Unit::TestCase fixtures :accounts, :companies, :developers, :projects, - :developers_projects, :topics + :developers_projects, :topics, :authors, :comments def setup Client.destroyed_client_ids.clear @@ -1014,14 +1015,21 @@ class HasManyAssociationsTest < Test::Unit::TestCase end def test_assign_ids_ignoring_blanks - firm = Firm.new("name" => "Apple") + firm = Firm.create!(:name => 'Apple') firm.client_ids = [companies(:first_client).id, nil, companies(:second_client).id, ''] - firm.save - firm.reload - assert_equal 2, firm.clients.length + firm.save! + + assert_equal 2, firm.clients(true).size assert firm.clients.include?(companies(:second_client)) end + def test_get_ids_for_through + assert_equal [comments(:eager_other_comment1).id], authors(:mary).comment_ids + end + + def test_assign_ids_for_through + assert_raise(NoMethodError) { authors(:mary).comment_ids = [123] } + end end class BelongsToAssociationsTest < Test::Unit::TestCase |