mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
fix test_find_in_association_with_options test, tweak other tests affected by developer/project addition
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3890 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
9b9a0908e5
commit
a0c459bca7
4 changed files with 21 additions and 17 deletions
|
@ -1090,7 +1090,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
|
|||
|
||||
active_record = Project.find(1)
|
||||
assert !active_record.developers.empty?
|
||||
assert_equal 2, active_record.developers.size
|
||||
assert_equal 3, active_record.developers.size
|
||||
assert active_record.developers.include?(david)
|
||||
end
|
||||
|
||||
|
@ -1282,7 +1282,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
|
|||
def test_uniq_before_the_fact
|
||||
projects(:active_record).developers << developers(:jamis)
|
||||
projects(:active_record).developers << developers(:david)
|
||||
assert_equal 2, projects(:active_record, :reload).developers.size
|
||||
assert_equal 3, projects(:active_record, :reload).developers.size
|
||||
end
|
||||
|
||||
def test_deleting
|
||||
|
@ -1290,13 +1290,13 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
|
|||
active_record = Project.find(1)
|
||||
david.projects.reload
|
||||
assert_equal 2, david.projects.size
|
||||
assert_equal 2, active_record.developers.size
|
||||
assert_equal 3, active_record.developers.size
|
||||
|
||||
david.projects.delete(active_record)
|
||||
|
||||
assert_equal 1, david.projects.size
|
||||
assert_equal 1, david.projects(true).size
|
||||
assert_equal 1, active_record.developers(true).size
|
||||
assert_equal 2, active_record.developers(true).size
|
||||
end
|
||||
|
||||
def test_deleting_array
|
||||
|
@ -1311,16 +1311,16 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
|
|||
david = Developer.find(1)
|
||||
active_record = Project.find(1)
|
||||
active_record.developers.reload
|
||||
assert_equal 2, active_record.developers_by_sql.size
|
||||
assert_equal 3, active_record.developers_by_sql.size
|
||||
|
||||
active_record.developers_by_sql.delete(david)
|
||||
assert_equal 1, active_record.developers_by_sql(true).size
|
||||
assert_equal 2, active_record.developers_by_sql(true).size
|
||||
end
|
||||
|
||||
def test_deleting_array_with_sql
|
||||
active_record = Project.find(1)
|
||||
active_record.developers.reload
|
||||
assert_equal 2, active_record.developers_by_sql.size
|
||||
assert_equal 3, active_record.developers_by_sql.size
|
||||
|
||||
active_record.developers_by_sql.delete(Developer.find(:all))
|
||||
assert_equal 0, active_record.developers_by_sql(true).size
|
||||
|
@ -1364,14 +1364,14 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_associations_with_conditions
|
||||
assert_equal 2, projects(:active_record).developers.size
|
||||
assert_equal 3, 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
|
||||
assert_equal 2, projects(:active_record, :reload).developers.size
|
||||
end
|
||||
|
||||
def test_find_in_association
|
||||
|
@ -1399,7 +1399,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
|
|||
def test_find_with_merged_options
|
||||
assert_equal 1, projects(:active_record).limited_developers.size
|
||||
assert_equal 1, projects(:active_record).limited_developers.find(:all).size
|
||||
assert_equal 2, projects(:active_record).limited_developers.find(:all, :limit => nil).size
|
||||
assert_equal 3, projects(:active_record).limited_developers.find(:all, :limit => nil).size
|
||||
end
|
||||
|
||||
def test_new_with_values_in_collection
|
||||
|
@ -1414,12 +1414,12 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
|
|||
assert project.developers.include?(david)
|
||||
end
|
||||
|
||||
def xtest_find_in_association_with_options
|
||||
def test_find_in_association_with_options
|
||||
developers = projects(:active_record).developers.find(:all)
|
||||
assert_equal 2, developers.size
|
||||
assert_equal 3, developers.size
|
||||
|
||||
assert_equal developers(:david), projects(:active_record).developers.find(:first, :conditions => "salary < 10000")
|
||||
assert_equal developers(:jamis), projects(:active_record).developers.find(:first, :order => "salary DESC")
|
||||
assert_equal developers(:poor_jamis), projects(:active_record).developers.find(:first, :conditions => "salary < 10000")
|
||||
assert_equal developers(:jamis), projects(:active_record).developers.find(:first, :order => "salary DESC")
|
||||
end
|
||||
|
||||
def test_replace_with_less
|
||||
|
|
|
@ -181,7 +181,7 @@ class DeprecatedAssociationsTest < Test::Unit::TestCase
|
|||
|
||||
active_record = Project.find(1)
|
||||
assert active_record.has_developers?
|
||||
assert_equal 2, active_record.developers_count
|
||||
assert_equal 3, active_record.developers_count
|
||||
assert active_record.developers.include?(david)
|
||||
end
|
||||
|
||||
|
@ -192,7 +192,7 @@ class DeprecatedAssociationsTest < Test::Unit::TestCase
|
|||
david.remove_projects(active_record)
|
||||
|
||||
assert_equal 1, david.projects_count
|
||||
assert_equal 1, active_record.developers_count
|
||||
assert_equal 2, active_record.developers_count
|
||||
end
|
||||
|
||||
def test_has_and_belongs_to_many_zero
|
||||
|
|
|
@ -339,7 +339,7 @@ class FinderTest < Test::Unit::TestCase
|
|||
:joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id',
|
||||
:conditions => 'project_id=1'
|
||||
)
|
||||
assert_equal 2, developers_on_project_one.length
|
||||
assert_equal 3, developers_on_project_one.length
|
||||
developer_names = developers_on_project_one.map { |d| d.name }
|
||||
assert developer_names.include?('David')
|
||||
assert developer_names.include?('Jamis')
|
||||
|
|
|
@ -11,3 +11,7 @@ david_active_record:
|
|||
jamis_active_record:
|
||||
developer_id: 2
|
||||
project_id: 1
|
||||
|
||||
poor_jamis_active_record:
|
||||
developer_id: 11
|
||||
project_id: 1
|
Loading…
Reference in a new issue