1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove tests that limit/offset without order which is non-deterministic result

The intent of that tests is completely covered by with order version.
This commit is contained in:
Ryuta Kamizono 2019-10-18 04:21:51 +09:00
parent c8d6a0a214
commit 3dc1e0c9a5

View file

@ -63,33 +63,18 @@ class UpdateAllTest < ActiveRecord::TestCase
assert_equal pets.count, pets.update_all(name: "Bob")
end
def test_update_all_with_joins_and_limit
comments = Comment.joins(:post).where("posts.id" => posts(:welcome).id).limit(1)
assert_equal 1, comments.update_all(post_id: posts(:thinking).id)
assert_equal posts(:thinking), comments(:greetings).post
end
def test_update_all_with_joins_and_limit_and_order
comments = Comment.joins(:post).where("posts.id" => posts(:welcome).id).order("comments.id").limit(1)
assert_equal 1, comments.count
assert_equal 1, comments.update_all(post_id: posts(:thinking).id)
assert_equal posts(:thinking), comments(:greetings).post
assert_equal posts(:welcome), comments(:more_greetings).post
end
def test_update_all_with_joins_and_offset
all_comments = Comment.joins(:post).where("posts.id" => posts(:welcome).id)
count = all_comments.count
comments = all_comments.offset(1)
assert_equal count - 1, comments.update_all(post_id: posts(:thinking).id)
end
def test_update_all_with_joins_and_offset_and_order
all_comments = Comment.joins(:post).where("posts.id" => posts(:welcome).id).order("posts.id", "comments.id")
count = all_comments.count
comments = all_comments.offset(1)
assert_equal count - 1, comments.update_all(post_id: posts(:thinking).id)
comments = Comment.joins(:post).where("posts.id" => posts(:welcome).id).order("comments.id").offset(1)
assert_equal 1, comments.count
assert_equal 1, comments.update_all(post_id: posts(:thinking).id)
assert_equal posts(:thinking), comments(:more_greetings).post
assert_equal posts(:welcome), comments(:greetings).post
end