aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/test/associations_go_eager_test.rb14
-rwxr-xr-xactiverecord/test/associations_test.rb7
2 files changed, 15 insertions, 6 deletions
diff --git a/activerecord/test/associations_go_eager_test.rb b/activerecord/test/associations_go_eager_test.rb
index 4e9c006d84..f345656cc2 100644
--- a/activerecord/test/associations_go_eager_test.rb
+++ b/activerecord/test/associations_go_eager_test.rb
@@ -222,17 +222,23 @@ class EagerAssociationTest < Test::Unit::TestCase
def test_preconfigured_includes_with_has_many
posts = authors(:david).posts_with_comments
- assert_equal 2, posts.first.comments.size
+ one = posts.detect { |p| p.id == 1 }
+ assert_equal 5, posts.size
+ assert_equal 2, one.comments.size
end
def test_preconfigured_includes_with_habtm
posts = authors(:david).posts_with_categories
- assert_equal 2, posts.first.categories.size
+ one = posts.detect { |p| p.id == 1 }
+ assert_equal 5, posts.size
+ assert_equal 2, one.categories.size
end
def test_preconfigured_includes_with_has_many_and_habtm
posts = authors(:david).posts_with_comments_and_categories
- assert_equal 2, posts.first.comments.size
- assert_equal 2, posts.first.categories.size
+ one = posts.detect { |p| p.id == 1 }
+ assert_equal 5, posts.size
+ assert_equal 2, one.comments.size
+ assert_equal 2, one.categories.size
end
end
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index 699bc7a12f..735f012afe 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -1404,7 +1404,10 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
assert developer.save
developer.projects << project
developer.update_attribute("name", "Bruza")
- assert_equal 1, developer.connection.select_one("SELECT count(*) FROM developers_projects WHERE
- project_id = #{project.id} AND developer_id = #{developer.id}")["count(*)"].to_i
+ assert_equal 1, Developer.connection.select_value(<<-end_sql).to_i
+ SELECT count(*) FROM developers_projects
+ WHERE project_id = #{project.id}
+ AND developer_id = #{developer.id}
+ end_sql
end
end