Merge branch '19954-permission-dedup-doc'
[arvados.git] / apps / workbench / test / test_helper.rb
index 1d26deefa38bbe7c593d07d47dfe0d7d409cf49d..2e8ead94cdb5e46f905f8872ec1d7b84ddec1f87 100644 (file)
@@ -158,7 +158,7 @@ class ActiveSupport::TestCase
     }
   end
   def json_response
-    Oj.load(@response.body)
+    Oj.safe_load(@response.body)
   end
 end
 
@@ -348,3 +348,30 @@ end
 
 # Reset fixtures now (i.e., before any tests run).
 ActiveSupport::TestCase.reset_api_fixtures_now
+
+module Minitest
+  class Test
+    def capture_exceptions *args
+      begin
+        n = 0
+        begin
+          yield
+        rescue *PASSTHROUGH_EXCEPTIONS
+          raise
+        rescue Exception => e
+          n += 1
+          raise if n > 2 || e.is_a?(Skip)
+          STDERR.puts "Test failed, retrying (##{n})"
+          ActiveSupport::TestCase.reset_api_fixtures_now
+          retry
+        end
+      rescue *PASSTHROUGH_EXCEPTIONS
+        raise
+      rescue Assertion => e
+        self.failures << e
+      rescue Exception => e
+        self.failures << UnexpectedError.new(e)
+      end
+    end
+  end
+end