test.rb 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # frozen_string_literal: true
  2. require 'active_support/core_ext/integer/time'
  3. # The test environment is used exclusively to run your application's
  4. # test suite. You never need to work with it otherwise. Remember that
  5. # your test database is "scratch space" for the test suite and is wiped
  6. # and recreated between test runs. Don't rely on the data there!
  7. Rails.application.configure do
  8. # Settings specified here will take precedence over those in config/application.rb.
  9. # Turn false under Spring and add config.action_view.cache_template_loading = true.
  10. config.cache_classes = true
  11. # Eager loading loads your whole application. When running a single test locally,
  12. # this probably isn't necessary. It's a good idea to do in a continuous integration
  13. # system, or in some way before deploying your code.
  14. config.eager_load = ENV['CI'].present?
  15. config.assets_digest = false
  16. # Show full error reports and disable caching.
  17. config.consider_all_requests_local = true
  18. config.action_controller.perform_caching = false
  19. config.cache_store = :memory_store
  20. # Raise exceptions instead of rendering exception templates.
  21. config.action_dispatch.show_exceptions = false
  22. # Disable request forgery protection in test environment.
  23. config.action_controller.allow_forgery_protection = false
  24. config.action_mailer.perform_caching = false
  25. config.action_mailer.default_options = { from: 'notifications@localhost' }
  26. # Tell Action Mailer not to deliver emails to the real world.
  27. # The :test delivery method accumulates sent emails in the
  28. # ActionMailer::Base.deliveries array.
  29. config.action_mailer.delivery_method = :test
  30. # Print deprecation notices to the stderr.
  31. config.active_support.deprecation = :stderr
  32. config.x.otp_secret = '100c7faeef00caa29242f6b04156742bf76065771fd4117990c4282b8748ff3d99f8fdae97c982ab5bd2e6756a159121377cce4421f4a8ecd2d67bd7749a3fb4'
  33. # Generate random VAPID keys
  34. vapid_key = Webpush.generate_key
  35. config.x.vapid_private_key = vapid_key.private_key
  36. config.x.vapid_public_key = vapid_key.public_key
  37. # Raise exceptions when a reorder occurs in in_batches
  38. config.active_record.error_on_ignored_order = true
  39. # Raise exceptions for disallowed deprecations.
  40. config.active_support.disallowed_deprecation = :raise
  41. config.i18n.default_locale = :en
  42. config.i18n.fallbacks = true
  43. config.to_prepare do
  44. # Force Status to always be SHAPE_TOO_COMPLEX
  45. # Ref: https://github.com/mastodon/mastodon/issues/23644
  46. 10.times { |i| Status.allocate.instance_variable_set(:"@ivar_#{i}", nil) }
  47. end
  48. # Tell Active Support which deprecation messages to disallow.
  49. config.active_support.disallowed_deprecation_warnings = []
  50. # Raises error for missing translations.
  51. # config.i18n.raise_on_missing_translations = true
  52. # Annotate rendered view with file names.
  53. # config.action_view.annotate_rendered_view_with_filenames = true
  54. end
  55. Paperclip::Attachment.default_options[:path] = Rails.root.join('spec', 'test_files', ':class', ':id_partition', ':style.:extension')
  56. # set fake_data for pam, don't do real calls, just use fake data
  57. if ENV['PAM_ENABLED'] == 'true'
  58. Rpam2.fake_data =
  59. {
  60. usernames: Set['pam_user1', 'pam_user2'],
  61. servicenames: Set['pam_test', 'pam_test_controlled'],
  62. password: '123456',
  63. env: { email: 'pam@example.com' }
  64. }
  65. end
  66. # Catch serialization warnings early
  67. Sidekiq.strict_args!
  68. Redis.raise_deprecations = true