X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/03395937ba05b9e3192e346a355c691f45cc7c85..0a78f5a0efe0c88fddcd2ee91065f2a8da79055a:/apps/workbench/test/test_helper.rb diff --git a/apps/workbench/test/test_helper.rb b/apps/workbench/test/test_helper.rb index c1eed5cd7b..1195798312 100644 --- a/apps/workbench/test/test_helper.rb +++ b/apps/workbench/test/test_helper.rb @@ -1,4 +1,5 @@ -ENV["RAILS_ENV"] = "test" +ENV["RAILS_ENV"] = "test" if (ENV["RAILS_ENV"] != "diagnostics") + unless ENV["NO_COVERAGE_TEST"] begin require 'simplecov' @@ -21,6 +22,7 @@ end require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +require 'mocha/mini_test' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in @@ -36,6 +38,7 @@ class ActiveSupport::TestCase def teardown Thread.current[:arvados_api_token] = nil + Thread.current[:reader_tokens] = nil super end end @@ -69,6 +72,9 @@ class ActiveSupport::TestCase arvados_api_token: api_fixture('api_client_authorizations')[api_client_auth_name.to_s]['api_token'] } end + def json_response + Oj.load(@response.body) + end end class ApiServerForTests @@ -126,7 +132,7 @@ class ApiServerForTests make_ssl_cert _system('bundle', 'exec', 'rake', 'db:test:load') _system('bundle', 'exec', 'rake', 'db:fixtures:load') - _system('bundle', 'exec', 'passenger', 'start', '-d', '-p3001', + _system('bundle', 'exec', 'passenger', 'start', '-d', '-p3000', '--pid-file', SERVER_PID_PATH, '--ssl', '--ssl-certificate', 'self-signed.pem', @@ -147,4 +153,26 @@ class ApiServerForTests end end -ApiServerForTests.run +class ActionController::TestCase + setup do + @counter = 0 + end + + def check_counter action + @counter += 1 + if @counter == 2 + assert_equal 1, 2, "Multiple actions in functional test" + end + end + + [:get, :post, :put, :patch, :delete].each do |method| + define_method method do |action, *args| + check_counter action + super action, *args + end + end +end + +if ENV["RAILS_ENV"].eql? 'test' + ApiServerForTests.run +end