test_helper.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. load "#{Rails.root}/test/fixtures/seeds.rb"
  22. # proccess background jobs
  23. Delayed::Worker.new.work_off
  24. # set system mode to done / to activate
  25. Setting.set('system_init_done', true)
  26. def setup
  27. # clear cache
  28. Cache.clear
  29. # set current user
  30. UserInfo.current_user_id = nil
  31. end
  32. # cleanup jobs
  33. def teardown
  34. # check if jobs are proccessed
  35. return if Delayed::Job.all.empty?
  36. Delayed::Job.where('failed_at != NULL').each {|job|
  37. assert( false, "not processable job #{job.inspect}" )
  38. }
  39. Delayed::Job.all.destroy_all
  40. end
  41. # Add more helper methods to be used by all tests here...
  42. end