X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d962404672ddd32804ddc7b8f502d01843e36404..55cc27092078a78847a2b0230e8782c744e7fff2:/apps/workbench/test/test_helper.rb diff --git a/apps/workbench/test/test_helper.rb b/apps/workbench/test/test_helper.rb index efb520a34c..1a07e43be1 100644 --- a/apps/workbench/test/test_helper.rb +++ b/apps/workbench/test/test_helper.rb @@ -22,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 @@ -35,10 +36,18 @@ class ActiveSupport::TestCase Thread.current[:arvados_api_token] = auth['api_token'] end - def teardown + teardown do Thread.current[:arvados_api_token] = nil + Thread.current[:user] = nil Thread.current[:reader_tokens] = nil - super + # Diagnostics suite doesn't run a server, so there's no cache to clear. + Rails.cache.clear unless (Rails.env == "diagnostics") + # Restore configuration settings changed during tests + $application_config.each do |k,v| + if k.match /^[^.]*$/ + Rails.configuration.send (k + '='), v + end + end end end @@ -49,7 +58,7 @@ module ApiFixtureLoader module ClassMethods @@api_fixtures = {} - def api_fixture(name) + def api_fixture(name, *keys) # Returns the data structure from the named API server test fixture. @@api_fixtures[name] ||= \ begin @@ -57,10 +66,16 @@ module ApiFixtureLoader 'test', 'fixtures', "#{name}.yml") YAML.load(IO.read(path)) end + keys.inject(@@api_fixtures[name]) { |hash, key| hash[key] } end end - def api_fixture name - self.class.api_fixture name + def api_fixture(name, *keys) + self.class.api_fixture(name, *keys) + end + + def find_fixture(object_class, name) + object_class.find(api_fixture(object_class.to_s.pluralize.underscore, + name, "uuid")) end end @@ -160,13 +175,7 @@ class ActionController::TestCase def check_counter action @counter += 1 if @counter == 2 - # TODO: when existing mistakes are fixed, start failing broken - # test cases like this: - # - # assert_equal 1, 2, "Multiple actions in functional test" - # - # Meanwhile, just warn (just once per test case): - $stderr.puts " [WARNING: Multiple actions in functional test]" + assert_equal 1, 2, "Multiple actions in functional test" end end