aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
diff options
context:
space:
mode:
authorTom Lea <contrib@tomlea.co.uk>2009-03-06 18:26:34 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-03-06 18:27:34 +0000
commitc896d56c6e5520346c260477f7d7f8bf951e72cc (patch)
tree1e146c83008067d7c50d0b00f879679c36805dd8 /activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
parent8bc0f90d6d5a6d653b9834e8bbca6ac20e25c293 (diff)
downloadrails-c896d56c6e5520346c260477f7d7f8bf951e72cc.tar.gz
rails-c896d56c6e5520346c260477f7d7f8bf951e72cc.tar.bz2
rails-c896d56c6e5520346c260477f7d7f8bf951e72cc.zip
Ensure self referential HABTM associations raise an exception if association_foreign_key is missing. [#1252 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
index 0f43d97f4a..9f5f34306d 100644
--- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -740,6 +740,14 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
assert_equal developer, project.developers.find(:first)
assert_equal project, developer.projects.find(:first)
end
+
+ def test_self_referential_habtm_without_foreign_key_set_should_raise_exception
+ assert_raise(ActiveRecord::HasAndBelongsToManyAssociationForeignKeyNeeded) {
+ Member.class_eval do
+ has_and_belongs_to_many :friends, :class_name => "Member", :join_table => "member_friends"
+ end
+ }
+ end
def test_dynamic_find_should_respect_association_include
# SQL error in sort clause if :include is not included