2024-05-17 18:12:31 -04:00
|
|
|
if ENV["COVERAGE"]
|
|
|
|
require "simplecov"
|
|
|
|
SimpleCov.start "rails" do
|
|
|
|
enable_coverage :branch
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-05-02 13:18:18 -04:00
|
|
|
# Test ENV setup:
|
|
|
|
# By default, all features should be disabled
|
|
|
|
# Use the `with_env_overrides` helper to enable features for individual tests
|
2024-04-18 07:56:51 -04:00
|
|
|
ENV["SELF_HOSTING_ENABLED"] = "false"
|
|
|
|
ENV["UPGRADES_ENABLED"] = "false"
|
2024-02-02 09:05:04 -06:00
|
|
|
ENV["RAILS_ENV"] ||= "test"
|
2024-05-02 13:18:18 -04:00
|
|
|
|
2024-05-08 08:17:46 -04:00
|
|
|
# Fixes Segfaults on M1 Macs when running tests in parallel (temporary workaround)
|
|
|
|
# https://github.com/ged/ruby-pg/issues/538#issuecomment-1591629049
|
|
|
|
ENV["PGGSSENCMODE"] = "disable"
|
|
|
|
|
2024-02-02 09:05:04 -06:00
|
|
|
require_relative "../config/environment"
|
|
|
|
require "rails/test_help"
|
2024-03-27 09:16:00 -06:00
|
|
|
require "minitest/mock"
|
|
|
|
require "minitest/autorun"
|
|
|
|
require "mocha/minitest"
|
|
|
|
|
|
|
|
VCR.configure do |config|
|
|
|
|
config.cassette_library_dir = "test/vcr_cassettes"
|
|
|
|
config.hook_into :webmock
|
|
|
|
config.ignore_localhost = true
|
|
|
|
config.default_cassette_options = { erb: true }
|
|
|
|
config.filter_sensitive_data("<SYNTH_API_KEY>") { ENV["SYNTH_API_KEY"] }
|
|
|
|
end
|
2024-02-02 09:05:04 -06:00
|
|
|
|
|
|
|
module ActiveSupport
|
|
|
|
class TestCase
|
|
|
|
# Run tests in parallel with specified workers
|
|
|
|
parallelize(workers: :number_of_processors)
|
|
|
|
|
2024-05-17 18:12:31 -04:00
|
|
|
# https://github.com/simplecov-ruby/simplecov/issues/718#issuecomment-538201587
|
|
|
|
if ENV["COVERAGE"]
|
|
|
|
parallelize_setup do |worker|
|
|
|
|
SimpleCov.command_name "#{SimpleCov.command_name}-#{worker}"
|
|
|
|
end
|
|
|
|
|
|
|
|
parallelize_teardown do |worker|
|
|
|
|
SimpleCov.result
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-02-02 09:05:04 -06:00
|
|
|
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
|
|
|
fixtures :all
|
|
|
|
|
|
|
|
# Add more helper methods to be used by all tests here...
|
2024-02-05 10:39:38 +11:00
|
|
|
def sign_in(user)
|
|
|
|
post session_path, params: { email: user.email, password: "password" }
|
|
|
|
end
|
2024-05-02 13:18:18 -04:00
|
|
|
|
|
|
|
def with_env_overrides(overrides = {}, &block)
|
|
|
|
ClimateControl.modify(**overrides, &block)
|
|
|
|
end
|
|
|
|
|
|
|
|
def with_self_hosting
|
|
|
|
Rails.configuration.stubs(:app_mode).returns("self_hosted".inquiry)
|
|
|
|
yield
|
|
|
|
end
|
2024-02-02 09:05:04 -06:00
|
|
|
end
|
|
|
|
end
|
2024-03-27 09:16:00 -06:00
|
|
|
|
|
|
|
Dir[Rails.root.join("test", "interfaces", "**", "*.rb")].each { |f| require f }
|