2010-04-20 23:05:11 +00:00
|
|
|
ENV["RAILS_ENV"] = "test"
|
2016-08-16 05:47:34 +09:00
|
|
|
|
2014-08-23 16:16:09 +09:00
|
|
|
require File.expand_path("../../config/environment", __FILE__)
|
|
|
|
require "rails/test_help"
|
2016-08-16 07:53:02 +09:00
|
|
|
require "minitest/spec"
|
2010-04-20 23:05:11 +00:00
|
|
|
|
2012-05-07 01:41:24 +07:00
|
|
|
class ActiveSupport::TestCase
|
2012-05-08 06:01:18 +00:00
|
|
|
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
|
|
|
#
|
|
|
|
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
|
|
|
# -- they do not yet inherit this setting
|
2014-11-20 11:53:07 +09:00
|
|
|
fixtures :all
|
2010-04-20 23:05:11 +00:00
|
|
|
|
2014-08-24 00:30:58 +09:00
|
|
|
def upload_file(path)
|
|
|
|
t = Tempfile.new File.basename(path)
|
|
|
|
FileUtils.copy_entry File.open(path, "rb"), t
|
|
|
|
t.rewind
|
|
|
|
t
|
|
|
|
end
|
2014-12-06 01:01:17 +09:00
|
|
|
|
2014-12-06 01:05:47 +09:00
|
|
|
setup :clear_cache
|
2014-12-06 01:01:17 +09:00
|
|
|
setup :reset_thread_variables
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2014-12-06 01:05:47 +09:00
|
|
|
def clear_cache
|
|
|
|
Rails.cache.clear
|
|
|
|
end
|
|
|
|
|
2014-12-06 01:01:17 +09:00
|
|
|
def reset_thread_variables
|
2024-01-08 19:39:01 +09:00
|
|
|
%w[danbooru-user danbooru-user_id versioning_history].each do |x|
|
2014-12-06 01:01:17 +09:00
|
|
|
Thread.current[x] = nil
|
|
|
|
end
|
|
|
|
end
|
2010-04-20 23:05:11 +00:00
|
|
|
end
|