闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.7 KiB

  1. ENV['RAILS_ENV'] ||= 'test'
  2. require File.expand_path('../../config/environment', __FILE__)
  3. abort("The Rails environment is running in production mode!") if Rails.env.production?
  4. require 'spec_helper'
  5. require 'rspec/rails'
  6. require 'webmock/rspec'
  7. require 'paperclip/matchers'
  8. require 'capybara/rspec'
  9. Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
  10. ActiveRecord::Migration.maintain_test_schema!
  11. WebMock.disable_net_connect!
  12. Sidekiq::Testing.inline!
  13. Sidekiq::Logging.logger = nil
  14. Devise::Test::ControllerHelpers.module_eval do
  15. alias_method :original_sign_in, :sign_in
  16. def sign_in(resource, deprecated = nil, scope: nil)
  17. original_sign_in(resource, scope: scope)
  18. SessionActivation.deactivate warden.raw_session["auth_id"]
  19. warden.raw_session["auth_id"] = resource.activate_session
  20. end
  21. end
  22. RSpec.configure do |config|
  23. config.fixture_path = "#{::Rails.root}/spec/fixtures"
  24. config.use_transactional_fixtures = true
  25. config.order = 'random'
  26. config.infer_spec_type_from_file_location!
  27. config.filter_rails_from_backtrace!
  28. config.include Devise::Test::ControllerHelpers, type: :controller
  29. config.include Devise::Test::ControllerHelpers, type: :view
  30. config.include Paperclip::Shoulda::Matchers
  31. config.include ActiveSupport::Testing::TimeHelpers
  32. config.before :each, type: :feature do
  33. https = ENV['LOCAL_HTTPS'] == 'true'
  34. Capybara.app_host = "http#{https ? 's' : ''}://#{ENV.fetch('LOCAL_DOMAIN')}"
  35. end
  36. end
  37. RSpec::Sidekiq.configure do |config|
  38. config.warn_when_jobs_not_processed_by_sidekiq = false
  39. end
  40. def request_fixture(name)
  41. File.read(File.join(Rails.root, 'spec', 'fixtures', 'requests', name))
  42. end
  43. def attachment_fixture(name)
  44. File.open(File.join(Rails.root, 'spec', 'fixtures', 'files', name))
  45. end