diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-08-19 14:56:58 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-08-19 14:56:58 +0000 |
commit | e96c58224c31c63b023b7f71e8f3ada440eb2fa8 (patch) | |
tree | 84335cb6ac8aa8c6cf5e2be29db646f0e7bd2de8 /activerecord/test/associations_join_model_test.rb | |
parent | 81b05fd9098c492bcf8651fe9042e5157d9a994b (diff) | |
download | rails-e96c58224c31c63b023b7f71e8f3ada440eb2fa8.tar.gz rails-e96c58224c31c63b023b7f71e8f3ada440eb2fa8.tar.bz2 rails-e96c58224c31c63b023b7f71e8f3ada440eb2fa8.zip |
unbraindeadify addition to has_many :through
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4791 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_join_model_test.rb')
-rw-r--r-- | activerecord/test/associations_join_model_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb index 0f6a5e76c2..1a0882fcfb 100644 --- a/activerecord/test/associations_join_model_test.rb +++ b/activerecord/test/associations_join_model_test.rb @@ -373,15 +373,28 @@ class AssociationsJoinModelTest < Test::Unit::TestCase count = posts(:thinking).tags.count push = Tag.create!(:name => 'pushme') assert_nothing_raised { posts(:thinking).tags << push } + assert_equal(count + 1, posts(:thinking).tags.size) assert_equal(count + 1, posts(:thinking).tags(true).size) assert_nothing_raised { posts(:thinking).tags.create!(:name => 'foo') } + assert_equal(count + 2, posts(:thinking).tags.size) assert_equal(count + 2, posts(:thinking).tags(true).size) assert_nothing_raised { posts(:thinking).tags.concat(Tag.create!(:name => 'abc'), Tag.create!(:name => 'def')) } + assert_equal(count + 4, posts(:thinking).tags.size) assert_equal(count + 4, posts(:thinking).tags(true).size) end + def test_adding_junk_to_has_many_through_should_raise_type_mismatch + assert_raise(ActiveRecord::AssociationTypeMismatch) { posts(:thinking).tags << "Uhh what now?" } + end + + def test_adding_to_has_many_through_should_return_self + tags = posts(:thinking).tags + assert_equal tags, posts(:thinking).tags.push(tags(:general)) + end + + def test_has_many_through_sum_uses_calculations assert_nothing_raised { authors(:david).comments.sum(:post_id) } end |