require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'mocha'
-require 'mocha/mini_test'
+require 'mocha/minitest'
module ArvadosTestSupport
def json_response
end
class ActiveSupport::TestCase
- include FactoryGirl::Syntax::Methods
+ include FactoryBot::Syntax::Methods
fixtures :all
include ArvadosTestSupport
class ActionController::TestCase
setup do
@test_counter = 0
+ self.request.headers['Accept'] = 'application/json'
+ self.request.headers['Content-Type'] = 'application/json'
end
def check_counter action
[:get, :post, :put, :patch, :delete].each do |method|
define_method method do |action, *args|
check_counter action
+ # After Rails 5.0 upgrade, some params don't get properly serialized.
+ # One case are filters: [['attr', 'op', 'val']] become [['attr'], ['op'], ['val']]
+ # if not passed upstream as a JSON string.
+ if args[0].is_a?(Hash) && args[0][:params].is_a?(Hash)
+ args[0][:params].each do |key, _|
+ next if key == :exclude_script_versions # Job Reuse tests
+ # Keys could be: :filters, :where, etc
+ if [Array, Hash].include?(args[0][:params][key].class)
+ args[0][:params][key] = SafeJSON.dump(args[0][:params][key])
+ end
+ end
+ end
super action, *args
end
end