diff options
Diffstat (limited to 'activerecord/test/associations_test.rb')
-rwxr-xr-x | activerecord/test/associations_test.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index f94908ced1..6076b10446 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -1278,17 +1278,20 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase def test_habtm_saving_multiple_relationships new_project = Project.new("name" => "Grimetime") amount_of_developers = 4 - developers = (0..amount_of_developers).collect {|i| Developer.create(:name => "JME #{i}") } - + developers = (0...amount_of_developers).collect {|i| Developer.create(:name => "JME #{i}") }.reverse + new_project.developer_ids = [developers[0].id, developers[1].id] new_project.developers_with_callback_ids = [developers[2].id, developers[3].id] assert new_project.save - + new_project.reload assert_equal amount_of_developers, new_project.developers.size - amount_of_developers.times do |i| - assert_equal developers[i].name, new_project.developers[i].name - end + assert_equal developers, new_project.developers + end + + def test_habtm_unique_order_preserved + assert_equal [developers(:poor_jamis), developers(:jamis), developers(:david)], projects(:active_record).non_unique_developers + assert_equal [developers(:poor_jamis), developers(:jamis), developers(:david)], projects(:active_record).developers end def test_build |