aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-03-05 11:34:39 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-03-05 11:34:39 +0000
commit0e8c3b8dd974a19855f41cb319579567449461ed (patch)
treef270237dcffab0ddc4c867fc74c2f441312de72a /activerecord/test
parentdf57f53d09575f8bc6542f87a3384240b66f9b4b (diff)
downloadrails-0e8c3b8dd974a19855f41cb319579567449461ed.tar.gz
rails-0e8c3b8dd974a19855f41cb319579567449461ed.tar.bz2
rails-0e8c3b8dd974a19855f41cb319579567449461ed.zip
Fix has_many :through << with custom foreign keys. Closes #6466, #7153.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6336 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/associations/join_model_test.rb7
-rw-r--r--activerecord/test/fixtures/vertex.rb2
2 files changed, 7 insertions, 2 deletions
diff --git a/activerecord/test/associations/join_model_test.rb b/activerecord/test/associations/join_model_test.rb
index 1124a0ace0..1d2a4f6c5c 100644
--- a/activerecord/test/associations/join_model_test.rb
+++ b/activerecord/test/associations/join_model_test.rb
@@ -6,10 +6,12 @@ require 'fixtures/comment'
require 'fixtures/author'
require 'fixtures/category'
require 'fixtures/categorization'
+require 'fixtures/vertex'
+require 'fixtures/edge'
class AssociationsJoinModelTest < Test::Unit::TestCase
self.use_transactional_fixtures = false
- fixtures :posts, :authors, :categories, :categorizations, :comments, :tags, :taggings, :author_favorites
+ fixtures :posts, :authors, :categories, :categorizations, :comments, :tags, :taggings, :author_favorites, :vertices
def test_has_many
assert authors(:david).categories.include?(categories(:general))
@@ -414,6 +416,9 @@ class AssociationsJoinModelTest < Test::Unit::TestCase
message = "Expected a Tagging in taggings collection, got #{wrong.class}.")
assert_equal(count + 4, post_thinking.tags.size)
assert_equal(count + 4, post_thinking.tags(true).size)
+
+ # Raises if the wrong reflection name is used to set the Edge belongs_to
+ assert_nothing_raised { vertices(:vertex_1).sinks << vertices(:vertex_5) }
end
def test_adding_junk_to_has_many_through_should_raise_type_mismatch
diff --git a/activerecord/test/fixtures/vertex.rb b/activerecord/test/fixtures/vertex.rb
index f4c11144de..48bb851e62 100644
--- a/activerecord/test/fixtures/vertex.rb
+++ b/activerecord/test/fixtures/vertex.rb
@@ -1,7 +1,7 @@
# This class models a vertex in a directed graph.
class Vertex < ActiveRecord::Base
has_many :sink_edges, :class_name => 'Edge', :foreign_key => 'source_id'
- has_many :sinks, :through => :sink_edges, :source => :sink
+ has_many :sinks, :through => :sink_edges
has_and_belongs_to_many :sources,
:class_name => 'Vertex', :join_table => 'edges',