mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6336 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Fix has_many :through << with custom foreign keys. #6466, #7153 [naffis, Rich Collins]
|
||||
|
||||
* Test DateTime native type in migrations. #7649 [fedot]
|
||||
|
||||
* SQLServer: correctly schema-dump tables with no indexes or descending indexes. #7333, #7703 [Jakob S, Tom Ward]
|
||||
|
||||
@@ -138,7 +138,7 @@ module ActiveRecord
|
||||
|
||||
# Construct attributes for :through pointing to owner and associate.
|
||||
def construct_join_attributes(associate)
|
||||
construct_owner_attributes(@reflection.through_reflection).merge(@reflection.source_reflection.association_foreign_key => associate.id)
|
||||
construct_owner_attributes(@reflection.through_reflection).merge(@reflection.source_reflection.primary_key_name => associate.id)
|
||||
end
|
||||
|
||||
# Associate attributes pointing to owner, quoted.
|
||||
|
||||
@@ -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
|
||||
|
||||
2
activerecord/test/fixtures/vertex.rb
vendored
2
activerecord/test/fixtures/vertex.rb
vendored
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user