File: fix-ramdom-failures.patch

package info (click to toggle)
ruby-protected-attributes 1.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 424 kB
  • ctags: 629
  • sloc: ruby: 2,269; makefile: 3
file content (33 lines) | stat: -rw-r--r-- 1,294 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From b12b823687f3549dbea699df7c109f1d54075754 Mon Sep 17 00:00:00 2001
From: Antonio Terceiro <terceiro@debian.org>
Date: Mon, 29 Aug 2016 15:26:19 -0300
Subject: [PATCH] attribute_sanitization_test: avoid random failures

Because test/test_helper.rb sets the tests to run on random order, that
missing call to `super` will cause tests to crash with the following
exception, depending on which order the test classes get loaded.

```
ActiveRecord::RecordNotUnique: SQLite3::ConstraintException: UNIQUE
constraint failed: people.id: INSERT INTO "people" ("id", "first_name", "gender", "comments", "best_friend_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?)
```

On my tests, this seems to happen more or less 6% of the time (i.e. 3
out of 50 runs). With this change, I was able to make 50 runs without a
single failure.
---
 test/attribute_sanitization_test.rb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/attribute_sanitization_test.rb b/test/attribute_sanitization_test.rb
index da8fb03..e1d6123 100644
--- a/test/attribute_sanitization_test.rb
+++ b/test/attribute_sanitization_test.rb
@@ -16,6 +16,7 @@
 
 module MassAssignmentTestHelpers
   def teardown
+    super
     ActiveRecord::Base.send(:descendants).each do |klass|
       begin
         klass.delete_all