Skip to content

Commit b7a5bd6

Browse files
Fix the random failure of test_create_resets_cached_counters
- Tried specifying `id` for the `readers` records but it is interconnected with so many tests that many random tests started failing. - So switched to the approach of deleting all readers in the `create_resets_cached_counters` test.
1 parent 52b925f commit b7a5bd6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

activerecord/test/cases/associations/has_many_associations_test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,10 @@ def test_finder_bang_method_with_dirty_target
456456
end
457457

458458
def test_create_resets_cached_counters
459+
Reader.delete_all
460+
459461
person = Person.create!(first_name: "tenderlove")
462+
460463
post = Post.first
461464

462465
assert_equal [], person.readers
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
michael_welcome:
2+
id: 1
23
post_id: 1
3-
person: michael
4+
person_id: 1
45
first_post_id: 2
56

67
michael_authorless:
8+
id: 2
79
post_id: 3
8-
person: michael
10+
person_id: 1
911
first_post_id: 3

0 commit comments

Comments
 (0)