diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-04-25 05:49:14 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-04-25 05:49:14 +0000 |
commit | c61b10b62be9f57dd847242471b4a30da81f16d4 (patch) | |
tree | 3e355664201bbd0ec56d61e108763886399289d3 /activerecord/test | |
parent | 4251662c1a4dbec8c69d4ab1b677950a0b4cfb58 (diff) | |
download | rails-c61b10b62be9f57dd847242471b4a30da81f16d4.tar.gz rails-c61b10b62be9f57dd847242471b4a30da81f16d4.tar.bz2 rails-c61b10b62be9f57dd847242471b4a30da81f16d4.zip |
Raise error when trying to add to a has_many :through association. Use the Join Model instead. [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4265 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/associations_join_model_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb index 93cfd0084c..9bacbfc717 100644 --- a/activerecord/test/associations_join_model_test.rb +++ b/activerecord/test/associations_join_model_test.rb @@ -357,6 +357,14 @@ class AssociationsJoinModelTest < Test::Unit::TestCase assert_nil posts(:thinking).tags.find_by_name("General").attributes["tag_id"] end + def test_raise_error_when_adding_to_has_many_through + assert_raise(ActiveRecord::ReadOnlyAssociation) { posts(:thinking).tags << tags(:general) } + assert_raise(ActiveRecord::ReadOnlyAssociation) { posts(:thinking).tags.push tags(:general) } + assert_raise(ActiveRecord::ReadOnlyAssociation) { posts(:thinking).tags.concat tags(:general) } + assert_raise(ActiveRecord::ReadOnlyAssociation) { posts(:thinking).tags.build(:name => 'foo') } + assert_raise(ActiveRecord::ReadOnlyAssociation) { posts(:thinking).tags.create(:name => 'foo') } + end + private # create dynamic Post models to allow different dependency options def find_post_with_dependency(post_id, association, association_name, dependency) |