test.rb 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. # While tests run files are not watched, reloading is not necessary.
  10. config.enable_reloading = false
  11. # Eager loading loads your entire application. When running a single test locally,
  12. # this is usually not necessary, and can slow down your test suite. However, it's
  13. # recommended that you enable it in continuous integration systems to ensure eager
  14. # loading is working properly before deploying your code.
  15. config.eager_load = ENV['CI'].present?
  16. config.assets_digest = false
  17. # Show full error reports and disable caching.
  18. config.consider_all_requests_local = true
  19. config.action_controller.perform_caching = false
  20. config.cache_store = :memory_store
  21. # Raise exceptions instead of rendering exception templates.
  22. config.action_dispatch.show_exceptions = :rescuable
  23. # Disable request forgery protection in test environment.
  24. config.action_controller.allow_forgery_protection = false
  25. config.action_mailer.perform_caching = false
  26. config.action_mailer.default_options = { from: 'notifications@localhost' }
  27. # Tell Action Mailer not to deliver emails to the real world.
  28. # The :test delivery method accumulates sent emails in the
  29. # ActionMailer::Base.deliveries array.
  30. config.action_mailer.delivery_method = :test
  31. # Print deprecation notices to the stderr.
  32. config.active_support.deprecation = :stderr
  33. config.x.otp_secret = '100c7faeef00caa29242f6b04156742bf76065771fd4117990c4282b8748ff3d99f8fdae97c982ab5bd2e6756a159121377cce4421f4a8ecd2d67bd7749a3fb4'
  34. # Generate random VAPID keys
  35. vapid_key = Webpush.generate_key
  36. config.x.vapid_private_key = vapid_key.private_key
  37. config.x.vapid_public_key = vapid_key.public_key
  38. # Raise exceptions when a reorder occurs in in_batches
  39. config.active_record.error_on_ignored_order = true
  40. # Raise exceptions for disallowed deprecations.
  41. config.active_support.disallowed_deprecation = :raise
  42. config.i18n.default_locale = :en
  43. config.i18n.fallbacks = true
  44. config.to_prepare do
  45. # Force Status to always be SHAPE_TOO_COMPLEX
  46. # Ref: https://github.com/mastodon/mastodon/issues/23644
  47. 10.times { |i| Status.allocate.instance_variable_set(:"@ivar_#{i}", nil) }
  48. end
  49. # Tell Active Support which deprecation messages to disallow.
  50. config.active_support.disallowed_deprecation_warnings = []
  51. # Raises error for missing translations.
  52. # config.i18n.raise_on_missing_translations = true
  53. # Annotate rendered view with file names.
  54. # config.action_view.annotate_rendered_view_with_filenames = true
  55. # Raise error when a before_action's only/except options reference missing actions
  56. config.action_controller.raise_on_missing_callback_actions = true
  57. end
  58. Paperclip::Attachment.default_options[:path] = Rails.root.join('spec', 'test_files', ':class', ':id_partition', ':style.:extension')
  59. # Enable fake_data for PAM
  60. if ENV['PAM_ENABLED'] == 'true'
  61. Rpam2.fake_data =
  62. {
  63. usernames: Set['pam_user1', 'pam_user2'],
  64. servicenames: Set['pam_test', 'pam_test_controlled'],
  65. password: '123456',
  66. env: { email: 'pam@example.com' }
  67. }
  68. end
  69. # Catch serialization warnings early
  70. Sidekiq.strict_args!
  71. Redis.raise_deprecations = true