test_helper.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ENV['RAILS_ENV'] = 'test'
  2. require File.expand_path('../../config/environment', __FILE__)
  3. require 'rails/test_help'
  4. require 'cache'
  5. require 'simplecov'
  6. require 'simplecov-rcov'
  7. class ActiveSupport::TestCase
  8. # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
  9. #
  10. # Note: You'll currently still have to declare fixtures explicitly in integration tests
  11. # -- they do not yet inherit this setting
  12. SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
  13. SimpleCov.start
  14. fixtures :all
  15. # disable transactions
  16. self.use_transactional_fixtures = false
  17. # clear cache
  18. Cache.clear
  19. # load seeds
  20. load "#{Rails.root}/db/seeds.rb"
  21. # proccess background jobs
  22. Delayed::Worker.new.work_off
  23. # set system mode to done / to activate
  24. Setting.set('system_init_done', true)
  25. def setup
  26. # clear cache
  27. Cache.clear
  28. # set current user
  29. UserInfo.current_user_id = nil
  30. end
  31. # cleanup jobs
  32. def teardown
  33. # check if jobs are proccessed
  34. return if Delayed::Job.all.empty?
  35. Delayed::Job.where('failed_at != NULL').each {|job|
  36. assert( false, "not processable job #{job.inspect}" )
  37. }
  38. Delayed::Job.all.destroy_all
  39. end
  40. # Add more helper methods to be used by all tests here...
  41. end