r1307@iwill: jeremy | 2005-06-13 19:05:00 -0700

Ticket 1312 - Malformed habtm finder sql
 r1308@iwill:  jeremy | 2005-06-13 19:58:48 -0700
 Add a habtm with an unquoted condition to Project.
 r1309@iwill:  jeremy | 2005-06-13 19:59:46 -0700
 Space out habtm finder conditions.
 r1310@iwill:  jeremy | 2005-06-13 20:00:16 -0700
 Test habtm.find with quoted and unquoted conditions.
 r1311@iwill:  jeremy | 2005-06-13 20:00:25 -0700
 Update changelog


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1414 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper
2005-06-13 21:51:43 +00:00
parent 2e6f6ced42
commit 1d9905a67f
4 changed files with 12 additions and 6 deletions

View File

@@ -787,7 +787,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
end
def test_adding_multiple
aredridel = Developer.new("name" => "Aridridel")
aredridel = Developer.new("name" => "Aredridel")
aredridel.save
aredridel.projects.reload
aredridel.projects.push(Project.find(1), Project.find(2))
@@ -796,7 +796,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
end
def test_adding_a_collection
aredridel = Developer.new("name" => "Aridridel")
aredridel = Developer.new("name" => "Aredridel")
aredridel.save
aredridel.projects.reload
aredridel.projects.concat([Project.find(1), Project.find(2)])
@@ -807,7 +807,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
def test_habtm_adding_before_save
no_of_devels = Developer.count
no_of_projects = Project.count
aredridel = Developer.new("name" => "Aridridel")
aredridel = Developer.new("name" => "Aredridel")
aredridel.projects.concat([Project.find(1), p = Project.new("name" => "Projekt")])
assert aredridel.new_record?
assert p.new_record?
@@ -947,7 +947,10 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
def test_associations_with_conditions
assert_equal 2, projects(:active_record).developers.size
assert_equal 1, projects(:active_record).developers_named_david.size
assert_equal developers(:david), projects(:active_record).developers_named_david.find(developers(:david).id)
assert_equal developers(:david), projects(:active_record).salaried_developers.find(developers(:david).id)
projects(:active_record).developers_named_david.clear
assert_equal 1, projects(:active_record, :reload).developers.size
end

View File

@@ -1,6 +1,7 @@
class Project < ActiveRecord::Base
has_and_belongs_to_many :developers, :uniq => true
has_and_belongs_to_many :developers_named_david, :class_name => "Developer", :conditions => "name = 'David'", :uniq => true
has_and_belongs_to_many :salaried_developers, :class_name => "Developer", :conditions => "salary > 0"
has_and_belongs_to_many :developers_by_sql, :class_name => "Developer", :delete_sql => "DELETE FROM developers_projects WHERE project_id = \#{id} AND developer_id = \#{record.id}"
end
@@ -8,4 +9,4 @@ class SpecialProject < Project
def hello_world
"hello there!"
end
end
end